Skip to content

Commit

Permalink
v.0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ekatrukha committed Nov 30, 2023
1 parent 85fe2dc commit a804c05
Show file tree
Hide file tree
Showing 9 changed files with 2,243 additions and 46 deletions.
50 changes: 23 additions & 27 deletions src/main/java/bigtrace/BigTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,48 +167,44 @@ public void run(String arg)
if(!btload.initDataSourcesImageJ())
return;
}

if(btdata.sFileNameFullImg.endsWith(".xml"))
{
btdata.bSpimSource = true;
try {
if(!btload.initDataSourcesHDF5())
return;
} catch (SpimDataException e) {
e.printStackTrace();
IJ.showMessage("BigTrace: cannot open selected XML file.\nMaybe it is not BDV compartible HDF5?\nPlugin terminated.");
return;
}
}
else
//if(btdata.sFileNameFullImg.endsWith(".czi"))
{
btdata.bSpimSource = true;
String outLog = btload.initDataSourcesBioFormats();
if(outLog != null)
if(btdata.sFileNameFullImg.endsWith(".xml"))
{
IJ.error(outLog);
//IJ.showMessage("BigTrace: cannot open \n"+btdata.sFileNameFullImg+"\nMake sure it is image data that is BioFormats readable.\nPlugin terminated.");

try {
if(!btload.initDataSourcesHDF5())
return;
} catch (SpimDataException e) {
e.printStackTrace();
IJ.showMessage("BigTrace: cannot open selected XML file.\nMaybe it is not BDV compartible HDF5?\nPlugin terminated.");
return;
}
}

}

//try BioFormats
else
{
String outLog = btload.initDataSourcesBioFormats();
if(outLog != null)
{
IJ.error(outLog);
//IJ.showMessage("BigTrace: cannot open \n"+btdata.sFileNameFullImg+"\nMake sure it is image data that is BioFormats readable.\nPlugin terminated.");
return;
}

}
}
if(sources == null)
{
IJ.showMessage("Currently BigTrace supports only TIF and BDV XML/HDF5 formats.");
return;
}



roiManager = new RoiManager3D(this);
initSourcesCanvas(0.25*Math.min(btdata.nDimIni[1][0], Math.min(btdata.nDimIni[1][1],btdata.nDimIni[1][2])));



initSourcesCanvas(0.25*Math.min(btdata.nDimIni[1][0], Math.min(btdata.nDimIni[1][1],btdata.nDimIni[1][2])));


//not sure we really need it, but anyway
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
Expand Down
64 changes: 46 additions & 18 deletions src/main/java/bigtrace/BigTraceLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
import java.util.ArrayList;
import javax.swing.JOptionPane;


import bdv.util.volatiles.VolatileViews;
import bigtrace.io.OpenerSettingsBT;
import bigtrace.io.SpimDataByteToShortOpener;
import bigtrace.volume.VolumeMisc;
import btbvv.vistools.BvvFunctions;
import btbvv.vistools.BvvSource;
import ch.epfl.biop.bdv.img.OpenersToSpimData;
import ch.epfl.biop.bdv.img.opener.OpenerSettings;
import ij.CompositeImage;
Expand All @@ -22,8 +26,11 @@
import loci.common.services.ServiceFactory;
import loci.formats.ChannelSeparator;
import loci.formats.FormatException;
import loci.formats.FormatTools;
import loci.formats.meta.MetadataRetrieve;
import loci.formats.services.OMEXMLService;
import loci.plugins.BF;
import loci.plugins.in.ImporterOptions;
import loci.plugins.util.ImageProcessorReader;
import loci.plugins.util.LociPrefs;
import mpicbg.spim.data.SpimData;
Expand All @@ -35,11 +42,17 @@
import net.imglib2.Interval;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.RealRandomAccessible;
import net.imglib2.cache.img.CellLoader;
import net.imglib2.cache.img.ReadOnlyCachedCellImgFactory;
import net.imglib2.cache.img.ReadOnlyCachedCellImgOptions;
import net.imglib2.cache.img.SingleCellArrayImg;
import net.imglib2.cache.img.optional.CacheOptions.CacheType;
import net.imglib2.img.Img;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.realtransform.RealViews;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.view.IntervalView;
import net.imglib2.view.Views;

Expand Down Expand Up @@ -71,7 +84,7 @@ public boolean initDataSourcesHDF5() throws SpimDataException
bt.sources = new ArrayList<IntervalView< T >>();

bt.spimData = new XmlIoSpimData().load( btdata.sFileNameFullImg );

bt.spimData.getSequenceDescription().getViewSetups();

final SequenceDescription seq = bt.spimData.getSequenceDescription();

Expand Down Expand Up @@ -128,6 +141,7 @@ public String initDataSourcesBioFormats()
String[] seriesName = null;

int[] seriesZsize = null;
int[] seriesBitDepth = null;

// check if multiple files inside, like LIF
try {
Expand All @@ -143,13 +157,15 @@ public String initDataSourcesBioFormats()
nSeriesCount = r.getSeriesCount();
seriesName = new String[nSeriesCount];
seriesZsize = new int[nSeriesCount];
seriesBitDepth = new int[nSeriesCount];

MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();
for (int nS=0;nS<nSeriesCount;nS++)
{
r.setSeries(nS);
seriesZsize[nS] = r.getSizeZ();
seriesName[nS] = retrieve.getImageName(nS);
seriesBitDepth[nS] = r.getPixelType();
}
r.close();
}
Expand All @@ -176,7 +192,7 @@ public String initDataSourcesBioFormats()
{
//make a list of 3D series
int outCount = 0;
for(int nS=0;nS<nSeriesCount;nS++)
for(int nS=0;nS<nSeriesCount; nS++)
{
if(seriesZsize[nS] > 1)
{
Expand All @@ -190,13 +206,15 @@ public String initDataSourcesBioFormats()

String [] nDatasetNames = new String[outCount];
int [] nDatasetIDs = new int[outCount];
int [] nDatasetType = new int[outCount];
int nCurrDS = 0;
for(int nS=0;nS<nSeriesCount;nS++)
{
if(seriesZsize[nS] > 1)
{
nDatasetNames[nCurrDS] = seriesName[nS];
nDatasetIDs[nCurrDS] = nS;
nDatasetType[nCurrDS] = seriesBitDepth[nS];
nCurrDS++;
}
}
Expand All @@ -209,18 +227,33 @@ public String initDataSourcesBioFormats()
nOpenSeries = nDatasetIDs[openDatasetN.getNextChoiceIndex()];

}


OpenerSettings settings = OpenerSettings.BioFormats()
.location(new File(btdata.sFileNameFullImg))
.unit( "MICROMETER")
.setSerie(nOpenSeries)
.positionConvention("TOP LEFT");



if(seriesBitDepth[nOpenSeries] == FormatTools.UINT16)
{
OpenerSettings settings = OpenerSettings.BioFormats()
.location(new File(btdata.sFileNameFullImg))
.unit("MICROMETER")
.setSerie(nOpenSeries)
.positionConvention("TOP LEFT");
bt.spimData = (SpimData) OpenersToSpimData.getSpimData(settings);

}
else if (seriesBitDepth[nOpenSeries] == FormatTools.UINT8)
{
OpenerSettingsBT settings = OpenerSettingsBT.BioFormats()
.location(new File(btdata.sFileNameFullImg))
.unit("MICROMETER")
.setSerie(nOpenSeries)
.positionConvention("TOP LEFT");
bt.spimData = (SpimData) SpimDataByteToShortOpener.getSpimData(settings);
}
else
{
return "Sorry, only 8- and 16-bit BioFormats images are supported.\nClosing BigTrace.";
}

bt.spimData = (SpimData) OpenersToSpimData.getSpimData(settings);

final SequenceDescription seq = bt.spimData.getSequenceDescription();

//get voxel size
Expand All @@ -247,16 +280,11 @@ public String initDataSourcesBioFormats()
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
// yes option
bt.bTestLLSTransform = true;
} else {
// no option
}

}
}

}



FinalInterval rai_int;
RandomAccessibleInterval<T> raitest = (RandomAccessibleInterval<T>) seq.getImgLoader().getSetupImgLoader(0).getImage(0);

Expand Down
Loading

0 comments on commit a804c05

Please sign in to comment.