-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DICOM export in ImageJ #4215
Conversation
This caused a problem when exporting DICOM with multiple channels from ImageJ, as the DICOM writer strictly requires non-null SamplesPerPixel on every Channel.
Shouldn't affect bfconvert, but does affect ImageJ export which calls close() twice.
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the current release JARS (7.3.1) shipped in the Java-8 distribution, I was able to reproduce the exception described in the PR while exporting the sample file as a DICOM.
Using the JARs built from this branch and replacing them in my local distribution, the same sample file exports successfully using the exporter and can be reopened with the plugin.
Testing the export of a few other sample files, I came across another NPE using ``File > Open Samples > Cardio (RGB DICOM)` and selecting the Bio-Formats exporter to create a DICOM
java.lang.NullPointerException
at loci.formats.out.DicomWriter.setId(DicomWriter.java:1057)
at loci.formats.FormatWriter.changeOutputFile(FormatWriter.java:123)
at loci.plugins.out.Exporter.run(Exporter.java:815)
at loci.plugins.LociExporter.run(LociExporter.java:75)
at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:266)
at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
at ij.IJ.runUserPlugIn(IJ.java:246)
at ij.IJ.runPlugIn(IJ.java:210)
at ij.IJ.runPlugIn(IJ.java:199)
at loci.plugins.shortcut.ShortcutPanel$1.run(ShortcutPanel.java:189)
Suppressed: java.lang.NullPointerException
at loci.formats.out.DicomWriter.writeIFDs(DicomWriter.java:2008)
at loci.formats.out.DicomWriter.close(DicomWriter.java:1402)
at loci.plugins.out.Exporter.run(Exporter.java:343)
... 7 more
Is that something we also want to fix as part of this PR?
ab8234f is one way to handle, but open to other ideas. |
No objections to this approach from my side. The proposal is very similar to glencoesoftware/omero-ms-image-region#99 which was addressing a very similar use case. In the same spirit, could the private method handle separately the |
Successfully tested by exporting a few ImageJ samples ( Noticed that if all DICOM files are exported in the same folder, the initialization fails as I assume the reader tries to read multiple DICOM files in the same directory. But this is the current behavior and was not introduced by this PR |
See https://forum.image.sc/t/exporting-a-dicom-stack/99400/6
I was able to reproduce the exception in that thread using ImageJ + Bio-Formats 7.3.1 by selecting
File > Open Samples > Organ of Corti...
, thenPlugins > Bio-Formats > Bio-Formats Exporter
and saving to a file with the.dcm
extension.With this change, the same test should result in a converted
.dcm
file (with no exception) that can be re-opened.