Skip to content

Instantly share code, notes, and snippets.

View flowernert's full-sized avatar

Florian Wernert flowernert

View GitHub Profile
@flowernert
flowernert / sliceChooser.ijm
Last active December 15, 2022 11:04
ImageJ/Fiji script allowing to QUICKLY go through a multichannel .tif z-stack to select for each image which slice you want to keep, then save it in a separate folder
/**
* Macro allowing to select a single slice for each image in a multicolor
* z-stack hyperstack
* Works from tif monochannel folder (XXX ext split) containing z-stacks
*
*/
dir = getDir("Select a folder");
outputDir = File.getParent(dir) + File.separator + File.getName(dir)+ " 1slice/";
@flowernert
flowernert / multiple_ROIs_helper.ijm
Last active November 25, 2022 11:17
ImageJ FiJi : retrieving indices or names of multiple selected ROIs
//returns an array of selected ROIs numeric indices
function getSelectedROIsIndexes() {
//calls existing java method, then parse it to an ImageJ Macro langage Array
rois = eval("script","java.util.Arrays.toString(RoiManager.getInstance().getSelectedIndexes())");
rois = substring(rois, indexOf(rois, "[")+1, lastIndexOf(rois, "]"));
rois = split(rois, ",");
selectedRois = newArray(rois.length);
for (i = 0; i < rois.length; i++) {
selectedRois[i] = parseInt(rois[i]);
@flowernert
flowernert / check_metadata.ijm
Last active December 21, 2022 15:23
ImageJ/FiJi check microscope acquisition parameters consistency
// Intensity and exposure labels
var labelChName = "Information|Image|Channel|Name #"; //ok
var labelChLaser = "Information|Image|Channel|Intensity #"; //ok most of the times
var labelChExposure = "Information|Image|Channel|ExposureTime #"; //ok but needs to be divided
//var labelCh1Name = "Experiment|AcquisitionBlock|MultiTrackSetup|Track|Channel|Name #1";
//var labelChLaser = "Experiment|HardwareSettingsPool|HardwareSetting|ParameterCollection|Intensity #1";
//var labelCh1exposure = "Experiment|AcquisitionBlock|MultiTrackSetup|Track|Channel|DataGrabberSetup|CameraFrameSetup|ExposureTime #1";
@flowernert
flowernert / shift RoiSet numbering.ijm
Last active November 24, 2022 10:41
ImageJ shift RoiSet numbering : rename your ROIs first 4 numbers (the xxxx in your ROI xxxx-yyyy-zzzz) by shifting the numbering according to value giver in the Dialog. Useful for ROIs generated on a stack that was not yet complete and some images have been appended to the beginning of the stack later on.
// licensed CC BY-NC-SA Florian Wernert
macro "shift RoiSet numbering" {
roiManager("select", 0);
roi1_name = split(Roi.getName(), "-");
min_val = -1* (parseInt(roi1_name[0]) - 1);
max_val = pow(2, 16);
@flowernert
flowernert / autocorrel_analysis.py
Last active March 9, 2020 12:45
ImageJ (Fiji) STORM microscopy autocorrelation analysis
import pandas as pd
import os
import sys
csv_autocor_name = "Recs TS proc (xy16).tif_AC(l1,w0)_Autocorr.csv"
def export_to_csv(sheets, analyzis_path):
for k, v in sheets.items():
v.to_csv(os.path.join(analyzis_path, k + ".csv"), index=None)
@flowernert
flowernert / flo-dl.md
Last active November 22, 2019 18:16
Youtube video to audio mp3

Youtube to MP3 downloader/converter

Prototype to be able to export the audio from a Youtube video and make it available to my smartphone.

Use case : keeping video as offline podcasts I can listen in the metro when there's no cell network available.

Linux only.

Uses the excellent https://github.com/ytdl-org/youtube-dl

@flowernert
flowernert / polar_gradient.c
Created January 26, 2019 16:42
Draw polar gradients for arcs and circle in Cairo as no native function in the library handles it. Done by drawing portions of arcs with incremental color steps.
/**
* Draws an arc with a B&W gradient following the arc path.
* cr: the Cairo object to draw to
* lw: the linewidth
* nb_steps: the number of segments/color increments in which the arc will be splitted
* x_center: the x coordinate of the center of the arc
* y_center: the y coordinate of the center of the arc
* radius: the radius of the arc
* angle_from: the angle from which the arc will begin
* angle_to: the angle at which the arc will end
class PlotContour(PlotBase):
... #some other methods generating the simplices plotting them and calling the contour method
@classmethod
def contour(cls, simplices, ax):
"""
:param simplices: the list of 3D simplices
:param ax: the Axes3D object
"""
@flowernert
flowernert / vispy_glsl_voronoi_mesh.py
Created November 23, 2018 16:25
(commented code is the interesting stuff) faster multiples calls to openGL draw
def on_draw(self, event):
#can be optimized if drawing 1 polyhedron per loop rather than 1 polyhedron's polygon per loop
gloo.clear()
self.program.draw(mode="lines", indices=self.indices)
# self.context.glir.associate(self.program.glir)
# for i in self.indices:
# self.context.glir.associate(i.glir)
# selection = i.id, "UNSIGNED_SHORT", i.size
# self.context.glir.command('DRAW', self.program._id, "line_strip", selection)