Created
March 29, 2021 09:14
-
-
Save NicoKiaru/558b26558260a3de96348996ac50d674 to your computer and use it in GitHub Desktop.
Takes a Nikon ND2 file and visualizes it lazily in BigDataViewer #BIOP #Fiji #BigDataViewer #NikonStereology
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You need to activate https://biop.epfl.ch/Fiji-Bdv-Playground/ for this script to function | |
// It takes a Nikon ND2 file and Visualizes it lazily in BigDataViewer, also opens some windows to control Brightness | |
// Of each channel present in the file | |
// Nicolas Chiaruttini, BIOP, EPFL, 2021 | |
#@CommandService cs | |
#@SourceAndConverterService sac_service | |
#@File(label="Select your Nikon ND2 file (single timepoint only)", style="open") nikonNd2File | |
// Opens Nikon nd2 dataset ( = multi series ) | |
def dataset = cs.run(BasicOpenFilesWithBigdataviewerBioformatsBridgeCommand.class, true, | |
"unit", "MICROMETER", | |
"files", [nikonNd2File] as File[], | |
"splitRGBChannels", false | |
).get().getOutput("spimData") | |
// Sets a meaningful name to the opened dataset - if not it is called SpimData 0 | |
sac_service.setSpimDataName(dataset, nikonNd2File.getName()) | |
// Uses the Bdv UI to fetch the number of series ( how many nodes are there below dataset>SeriesNumber ? | |
//def datasetPath = sac_service.getUI().getTreePathFromString(nikonNd2File.getName()+">SeriesNumber") | |
//def int number_of_channels = datasetPath.getLastPathComponent().getChildCount(); | |
cs.run(BdvSourcesShowCommand.class, true, | |
"autoContrast",false, | |
"adjustViewOnSource",true, | |
"is2D",false, | |
"windowTitle",nikonNd2File.getName(), | |
"interpolate",false, | |
"nTimepoints",1, | |
"projector","Average Projector", | |
"sacs", nikonNd2File.getName()).get() | |
cs.run(BasicTransformerCommand.class, true, | |
"type","Flip", | |
"axis","Y", | |
"timepoint",0, | |
"globalChange",false, | |
"sources_in", nikonNd2File.getName() | |
).get() | |
cs.run(BasicTransformerCommand.class, true, | |
"type","Flip", | |
"axis","X", | |
"timepoint",0, | |
"globalChange",false, | |
"sources_in", nikonNd2File.getName() | |
).get() | |
// Uses the Bdv UI to fetch the number of channels ( how many nodes are there below dataset>Channel ? | |
def datasetPath = sac_service.getUI().getTreePathFromString(nikonNd2File.getName()+">Channel") | |
def int number_of_channels = datasetPath.getLastPathComponent().getChildCount(); | |
for (int index_channel=0;index_channel<number_of_channels;index_channel++) { | |
cs.run(BrightnessAdjusterCommand.class, true, | |
"sources", nikonNd2File.getName()+">Channel>"+index_channel); | |
} | |
import ch.epfl.biop.bdv.bioformats.command.BasicOpenFilesWithBigdataviewerBioformatsBridgeCommand | |
import sc.fiji.bdvpg.scijava.command.source.SourcesRemoverCommand | |
import ch.epfl.biop.bdv.command.exporter.ExportToImagePlusCommand | |
import ij.plugin.Scaler | |
import ij.plugin.ZProjector | |
import ij.IJ | |
import org.apache.commons.io.FilenameUtils | |
import ch.epfl.biop.bdv.bioformats.imageloader.SeriesNumber | |
import groovyx.gpars.GParsExecutorsPool | |
import sc.fiji.bdvpg.scijava.command.bdv.BdvSourcesShowCommand | |
import sc.fiji.bdvpg.scijava.command.source.BasicTransformerCommand | |
import sc.fiji.bdvpg.scijava.command.source.BrightnessAdjusterCommand |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment