.nrrd files with 4 dimensions are incompatible for processing in other software

Hello everyone! I use Slicer to process MicroCT scans of fossils of marine microorganisms- so my objectives are probably somewhat different than several of my fellow users. I faced a n issue with my data processing workflow and will do my best to describe it here.

After reconstruction of the CT Scans using nRecon, I used to save them as .TIFF files, then convert them to .nrrd files using Slicer. After that, I would process the files using a code I wrote in MATLAB, where I would extract the CT number of each voxel and create histograms of the density distribution of each fossil specimen.

Recently, the lab in which I do my scans has recommended that we save the reconstructed images in the .PNG format. I have converted them to .nrrd using Slicer, however, the files generated by Slicer are not readable by the .nrrdread function in MATLAB. There are several differences that show up in the metadata of the .nrrd’s that I was able to generate earlier vs the newest ones (images below). does anyone have any idea how the files can maintain their compatibility across softwares?

Is there a way to generate CT numbers using Slicer itself, without having to transfer the files over to MATLAB? I am happy to discuss the code and my workflow in detail with anyone who is interested! Many thanks.
Previous files:
Screenshot 2023-08-01 170000_____

New files:
Screenshot 2023-08-01 165901

I wonder if the PNG image files are being loaded with 3 color channels, whereas your TIFF files were a single channel. To recover the original CT image values, you would need to know what the transfer function converting CT image values to PNG pixel values was. If you are lucky, it may just be that the CT voxel value was copied directly into each of the 3 color channels. If that were the case, then you could just choose any channel and read the value back out.

At a higher level, you can almost certainly do your entire workflow using Slicer without needing to transfer anything to MATLAB. What format is the original data coming off the scanner in? Slicer doesn’t have any trouble reading DICOM files (which are what come off of medical CT scanners), but I’m not sure what formats are usually used for research MicroCT scanners. I believe that @muratmaga and the SlicerMorph community here work a lot with research CT scans of non-human skeletal and fossil data, and might be a great resource for you.

You can use this NRRD reader implementation:

I haven’t tested it recently (I stopped using Matlab and switched to Python 5-10 years ago), so maybe the script needs some small changes to use it in latest Matlab versions. But you may also consider switching to Python, because it is just so much more powerful and versatile and you can use Python almost anywhere. You can even run your processing code in Slicer’s embedded Python environment (you can hit using Ctrl-3 to open an interactive Python console where you can access all data that has been loaded into Slicer).

If you use the SkyscanReconImport from SlicerMorph, you can avoid the multichannel issue and import any format Nrecon provides as output (PNG/BMP/JPG/TIFF). If you want to give it a try, install the SlicerMorph extension, then switch to SkyScanReconImport module and simply navigate to the _REC.LOG file outputed by the Nrecon software.

1 Like

I question the wisdom of this suggestion. As you can see in your screenshots, the new data is unsigned char (8 bit) while the old files were unsigned short (16 bit). Since most CT scans have more dynamic range than can fit in 8 bits you are probably losing dynamic range and that can lead to artifacts in your reconstructions.

1 Like