Conversation
This notebook allows a single .AIM or .ISQ file, specified through the variable filename, to be imported and undergo operations for conversion from Hounsfield Units to Density in g/cc and to a binary image mask given user-specified image thresholds and numeric constants extracted from the image header metadata. These operations are NOT optimized and 2 main issues remain: 1. The image header metadata is incomplete, as noted by other users in 2 separate open issues. This workbook uses a template header to show proof of concept, but a finalized version will require header information extracted from each file separately. 2. Imported images have a high memory requirement for array operations needed to convert them to alternate units or a binary image mask. It may be necessary to optimize memory use to reduce required memory and increase throughput
Previous version implemented a binary thresholding operation through cv2.threshold. The new version uses itk.BinaryThresholdImageFilter to create a binarized volume version of the input image.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
| @@ -0,0 +1,227 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #1. import numpy as np
Before importing, can we first have a cell that installs all dependencies so the notebook is more reproducible? See, e.g. https://github.com/KitwareMedical/ITKIOScanco/blob/master/examples/ReadISQ.ipynb
Reply via ReviewNB
| @@ -0,0 +1,227 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #9. del all_AIM_filenames, all_ISQ_filenames
We can remove the del -- this is a Matlab-ism due to poor scoping in Matlab's lanugage. We generally do not need it Python.
Reply via ReviewNB
| @@ -0,0 +1,227 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #1. filename = 'C0005757_SCAP.AIM'
Can you download the file with the pooch package so the notebook is more reproducible?
Reply via ReviewNB
There was a problem hiding this comment.
For now I've implemented this using the example data referred to here. I'm not entirely sure how this is supposed to function in a general sense, since the URL provided in the example may not be the location where these images will be found. The hash value seems to be an important argument for pooch.retrieve as well, but it's not clear to me how this will be obtained.
| @@ -0,0 +1,227 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #4. print(metadata)
Can we save this cell's output in the notebook so it can be browsed on GitHub?
Reply via ReviewNB
There was a problem hiding this comment.
I'm approaching this as saving the metadata to a .txt file. If you had something else in mind, please let me know.
| @@ -0,0 +1,227 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #6. mu_threshHigh = 1.0
per Python naming conversions, snake_case is used for variable names. So mu_threshHigh -> mu_threshold_high, etc.
Reply via ReviewNB
| @@ -0,0 +1,227 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #7. reader.SetFileName(filename)
We want to use the more python itk.imread , itk.imwrite and itk.binary_threshold_image_filter See https://itkpythonpackage.readthedocs.io/en/master/Quick_start_guide.html
Reply via ReviewNB
| @@ -0,0 +1,227 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #17. BWoutname = filename[0:-4] + '_BWmask.nrrd'
from pathlib import Path
Path(filename)
-> remove the extension with this.
Reply via ReviewNB
| @@ -0,0 +1,247 @@ | |||
| { | |||
There was a problem hiding this comment.
| @@ -0,0 +1,247 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #5. print(metadata)
can we save the output here into the notebook so it can be viewed on GitHub?
Reply via ReviewNB
| @@ -0,0 +1,247 @@ | |||
| { | |||
There was a problem hiding this comment.
| @@ -0,0 +1,247 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #29. HU_values = [HU_pixel_low, HU_pixel_high]
Please print out all the relevant scalar values here at the end of the cell and save the output in the cell so people browsing the notebook online can see examples of typical values.
Reply via ReviewNB
This workbook outlines a process for converting SCANCO .AIM or .ISQ files to standard published units (hounsfield units and g/cc). This is a revised version of the original workbook, which now uses itk.BinaryThresholdImageFilter to create a binarized volume using low and high thresholds. These thresholds must be user-specified as they are not included in metadata for .AIM or .ISQ images.
Additionally, a few other constants are missing from the image metadata obtained from itk.imread which are required for unit conversion. A dummy file header is used in the workbook for the sake of enabling execution, but this will need to be revised in the long run.