Skip to content

Commit

Permalink
BioFormats file open corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
ekatrukha committed Feb 21, 2024
1 parent 97fb11f commit f2e868f
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions src/main/java/bigtrace/BigTraceLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public boolean initDataSourcesHDF5() throws SpimDataException
btdata.nTotalChannels = seq.getViewSetupsOrdered().size();


//TODO FOR NOW, get it from the class
//not really needed later, but anyway
//in the end always 16-bit
btdata.nBitDepth = 16;
colorsCh = new Color[btdata.nTotalChannels];
channelRanges = new double [2][btdata.nTotalChannels];
Expand All @@ -109,47 +108,43 @@ public boolean initDataSourcesHDF5() throws SpimDataException

}

@SuppressWarnings({ "unchecked", "resource" })
@SuppressWarnings({ "unchecked" })
public String initDataSourcesBioFormats()
{
DebugTools.setRootLevel("INFO");

//analyze file a bit
int nSeriesCount = 0;

ImageProcessorReader r = new ImageProcessorReader(
new ChannelSeparator(LociPrefs.makeImageReader()));

String[] seriesName = null;

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

// check if multiple files inside, like LIF
try {
try (ImageProcessorReader r = new ImageProcessorReader(
new ChannelSeparator(LociPrefs.makeImageReader()));)
{
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
r.setMetadataStore(service.createOMEXMLMetadata());
}
catch (DependencyException de) { }
catch (ServiceException se) { }
try {

r.setMetadataStore(service.createOMEXMLMetadata());
r.setId(btdata.sFileNameFullImg);

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.setId(btdata.sFileNameFullImg);
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();
}
catch (FormatException exc) {
return "Sorry, an error occurred: " + exc.getMessage();
Expand All @@ -158,6 +153,13 @@ public String initDataSourcesBioFormats()
catch (IOException exc) {
return "Sorry, an error occurred: " + exc.getMessage();
}
catch (DependencyException de) {
return "Sorry, an error occurred: " + de.getMessage();
}
catch (ServiceException se) {
return "Sorry, an error occurred: " + se.getMessage();
}

int nOpenSeries = 0;
if(nSeriesCount==1)
{
Expand Down Expand Up @@ -296,8 +298,7 @@ public String initDataSourcesBioFormats()
btdata.nBitDepth = 16;
colorsCh = new Color[btdata.nTotalChannels];
channelRanges = new double [2][btdata.nTotalChannels];



return null;

}
Expand Down

0 comments on commit f2e868f

Please sign in to comment.