Skip to content

Instantly share code, notes, and snippets.

@sbesson
Last active December 16, 2016 09:16
Show Gist options
  • Save sbesson/3c9f27de36339b5f2ae03b21599b20d2 to your computer and use it in GitHub Desktop.
Save sbesson/3c9f27de36339b5f2ae03b21599b20d2 to your computer and use it in GitHub Desktop.
A set of scripts to manipulate Zeiss CZI options in Bio-Formats
% Check Bio-Formats and initialize logging
bfCheckJavaPath();
bfInitLogging();
% Create a reader
r = bfGetReader();
values = [true false];
for autostich = values
for attachments = values
% Create a set of key/value options and pass it to the reader
m = loci.formats.in.DynamicMetadataOptions();
m.setBoolean(loci.formats.in.ZeissCZIReader.ALLOW_AUTOSTITCHING_KEY,...
java.lang.Boolean(autostich));
m.setBoolean(loci.formats.in.ZeissCZIReader.INCLUDE_ATTACHMENTS_KEY,...
java.lang.Boolean(attachments));
r.setMetadataOptions(m);
for flattenedResolutions = values
r.setFlattenedResolutions(flattenedResolutions);
% Initialize the reader with the file
r.setId(path_to_czi);
% Display metadata
fprintf(1, 'Autostitch: %g\n', autostich);
fprintf(1, 'Include attachments: %g\n', attachments);
fprintf(1, 'Flatten resolutions: %g\n', flattenedResolutions);
fprintf(1, 'Number of series: %g\n', r.getSeriesCount());
fprintf(1, 'Number of resolutions: %g\n', r.getResolutionCount());
fprintf(1, '\n');
% Close the reader
r.close();
end
end
end
// A macro derived from basicMetadata to set the CZI arguments
// Set option to disable auto-stitching and attachments
call("ij.Prefs.set", "bioformats.zeissczi.allow.autostitch", "false");
call("ij.Prefs.set", "bioformats.zeissczi.include.attachments", "false");
run("Bio-Formats Macro Extensions");
id = File.openDialog("Choose a file");
Ext.setId(id);
Ext.getSeriesCount(seriesCount);
for (s=0; s<seriesCount; s++) {
Ext.setSeries(s);
Ext.getSizeX(sizeX);
Ext.getSizeY(sizeY);
Ext.getSizeZ(sizeZ);
Ext.getSizeC(sizeC);
Ext.getSizeT(sizeT);
print("Series #" + s + ": image resolution is " + sizeX + " x " + sizeY);
print("Focal plane count = " + sizeZ);
print("Channel count = " + sizeC);
print("Time point count = " + sizeT);
}
Ext.close();
@bramalingam
Copy link

Both the scripts work. The only thing that I might like to add to the matlab script is a loop like the Fiji example, to print the series count etc. Then it would become a self-sufficient example and potentially a base script for a unit-test in future.

@sbesson
Copy link
Author

sbesson commented Dec 16, 2016

Thanks @bramalingam, done in 3c9f27de36339b5f2ae03b21599b20d2 and added the flattened resolutions call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment