-
Notifications
You must be signed in to change notification settings - Fork 1
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
Localizer based labeling #46
Conversation
b41af61
to
96c0ca8
Compare
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.
There is a lot of changes in this PR, so it is impossible for me to review all of them exhaustively. I could try the new segmentation method on data, but for that I would need instructions on how to test this new segmentation method (what command to run, etc.)
Thank you for reviewing the PR! Lines 51 to 86 in 07069b9
checkout this branch: cd totalspineseg && git checkout localizer-based-labeling && cd .. Lines 175 to 209 in 07069b9
|
Enhanced the segmentation script to include localizer images, enabling detection of the first vertebrae and disc when initial labels are absent. Introduced loc-suffix, loc-disc-labels, loc-vertebrea-labels, default-superior-disc, and default-superior-vertebrea parameters to improve labeling accuracy and reduce errors. Updated command-line arguments and processing steps accordingly. Implements #43
Updated help texts for '--loc-disc-labels' and '--loc-vertebrea-labels' to specify their use in the localizer for detecting first disc and vertebrae respectively. This improves the clarity of the argument purposes for better usability and understanding by end-users.
Expanded the help description for the --locs-dir argument to provide clearer instructions. Now it specifies that the localizer segmentations are transformed and used for detecting the first vertebrae and disc if the initial label is missing. This enhances user understanding, particularly in scenarios where the initial labeling is absent.
Extended inference script to support localizers segmentations, enhancing the detection of vertebrae and discs when certain reference points are missing in the images. Added new arguments for localizer directory, input and output suffixes, and adjusted the iterative labeling process to handle the additional configuration. This improves the robustness and flexibility of the inference process, especially in cases where standard detection is insufficient or fails due to missing landmarks.
Improved the clarity and precision of masking logic by introducing an intermediate variable, enhancing readability and reducing potential errors. Revised the calculation of the target label to align with the new masking approach for better accuracy. This change addresses potential edge cases where the masks intersect, ensuring more robust label handling.
Adjusted the conditional logic to ensure the localizer image is loaded only when the localizer path exists, addressing potential `NoneType` errors and improving robustness in image loading routines.
Enhanced README with instructions for using localizer images to improve vertebral labeling, addressing issues with varying fields of view. Included data structure description and example commands for processing. This ensures more accurate and consistent labeling across different image sets.
Refined document structure for better readability, including updating titles formatting and clarifying sections on localizer-based labeling. Ensured a single, accurate description of using localizer images to streamline and enhance label accuracy. Removed duplication and enhanced visual support with relevant image placement.
Condensed the section linking to the PDF preview by combining multiple lines into one for improved readability. This change helps streamline the document and makes it more concise.
Updated section titles in README to streamline and simplify 'Output Examples' to 'Examples'. This enhances readability and consistency in the document. No functional changes to the content.
d8810e6
to
30f3243
Compare
Renamed "Examples" section to "Results" to better reflect the content. This improves clarity by providing a more accurate description of the model's output display section.
Included an important note in the README about the limitations of the spinal cord segmentation provided by TotalSpineSeg. The added disclaimer highlights that this tool is not validated for CSA analysis and should not be used for assessing spinal cord compressions or MS lesions. Users are directed to use Spinal Cord Toolbox for validated CSA analysis tools.
Updated README and inference script to support processing of a single .nii.gz file in addition to folder inputs. Renamed arguments for consistency and improved help documentation. - `input_dir` to `input` - `output_dir` to `output` - `localizers-dir` to `loc` - `localizers-suffix` to `loc-suffix` These changes enhance usability by allowing more flexible model input options and clearer documentation.
Enhanced the disclaimer regarding the valid uses of TotalSpineSeg, emphasizing the lack of validation for cross-sectional area (CSA) measurements and various spinal conditions. Simplified explanation for omitting suffix arguments in cases where localizer and main images have identical names.
Enhanced the localizer search path to include nested directories, improving the comprehensiveness of localizer discovery. Added functionality to generate preview images for the localizers, assisting in quick visual validation. These changes streamline the workflow and enhance usability.
Corrected the spelling of "vertebrea" to "vertebrae" in various files to maintain consistency and accuracy in anatomical terminology. This change affects function parameters, documentation, and help texts, providing clearer and more professional codebase and usage instructions. Fix #44
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.
Issue:
julien-macbook:~/code/totalspineseg $ python3 -m venv venv
julien-macbook:~/code/totalspineseg $ source venv/bin/activate
(venv) julien-macbook:~/code/totalspineseg $ python3 -m pip install -e totalspineseg
Obtaining file:///Users/julien/code/totalspineseg/totalspineseg
ERROR: file:///Users/julien/code/totalspineseg/totalspineseg does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
[notice] A new release of pip is available: 23.0.1 -> 24.2
[notice] To update, run: pip install --upgrade pip
(venv) julien-macbook:~/code/totalspineseg $ pip install --upgrade pip
Requirement already satisfied: pip in ./venv/lib/python3.10/site-packages (23.0.1)
Collecting pip
Downloading pip-24.2-py3-none-any.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 33.7 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.0.1
Uninstalling pip-23.0.1:
Successfully uninstalled pip-23.0.1
Successfully installed pip-24.2
(venv) julien-macbook:~/code/totalspineseg $ python3 -m pip install -e totalspineseg
Obtaining file:///Users/julien/code/totalspineseg/totalspineseg
ERROR: file:///Users/julien/code/totalspineseg/totalspineseg does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
(venv) julien-macbook:~/code/totalspineseg $ ll
total 40
drwxr-xr-x 9 julien staff 288 10 Sep 16:52 .
drwxr-xr-x 43 julien staff 1376 10 Sep 16:52 ..
drwxr-xr-x 12 julien staff 384 10 Sep 16:52 .git
-rw-r--r-- 1 julien staff 3316 10 Sep 16:52 .gitignore
-rw-r--r-- 1 julien staff 10262 10 Sep 16:52 README.md
-rw-r--r-- 1 julien staff 3308 10 Sep 16:52 pyproject.toml
drwxr-xr-x 6 julien staff 192 10 Sep 16:52 scripts
drwxr-xr-x 6 julien staff 192 10 Sep 16:52 totalspineseg
drwxr-xr-x 6 julien staff 192 10 Sep 16:52 venv
correct instruction:
(venv) julien-macbook:~/code/totalspineseg $ python3 -m pip install -e .
nevermind-- i see that we were not supposed to go into the git cloned repos (which is usually common practice, so it's a bit confusing)-- i suggest to instruct to go into the repos and then install from there
Thank you!! this is actually confusing. We should make it more intuitive. cd totalspineseg
python3 -m pip install -e .
cd .. @jcohenadad should we change it like this? |
This is actually good point to discuss. The current implementation is not perfect. |
I wouldn't worry too much about these fine details, given that ultimately this method will be callable via SCT. But we should already think of an appropriate API to plug it inside SCT. Tagging @joshuacwnewton @mguaypaq so we can start thinking about it |
Thank you for the ping. I'll take a look at this first thing tomorrow and begin thinking about ways that this project can integrate with SCT. I appreciate you keeping us in the loop! :) EDIT: I've opened an issue (see below) for the topic of integrating TotalSpineSeg into SCT. So, feel free to proceed with this PR, and I'll keep an eye out from the SCT side of things to prepare for a potential future integration. :) |
Co-authored-by: Nathan Molinier <[email protected]>
Co-authored-by: Nathan Molinier <[email protected]>
Co-authored-by: Nathan Molinier <[email protected]>
Last question regarding this PR, as raised by @jcohenadad, what would be the best practice regarding the installation of the package ? Currently we ask the user to do this
But we were wondering if instead it would be more intuitive for the user to do this:
Do you have any recommandations on this @joshuacwnewton @mguaypaq ? |
Can we consider merge this PR and open an issue for that as this is not related to something that changed in this PR? |
Agree with @yw7 -- Please feel free to tag me on any new issues discussing installation/packaging. :) |
Currently, the iterative_label.py script does not support images without any of the landmarks (C2, T1, T12, Sacrum).
To solve this issue, we can update the iterative_label.py script to get localizer segmentation as an input to initialize labels for discs and vertebrae. The localizer have to be in same space, but no need for exact match, only that most of the voxels in the first vertebrae and disc will be overlapping with the provided image. The script acts as follows:
Instructions for new localizer based labeling:
totalspineseg/README.md
Lines 51 to 86 in 07069b9
checkout this branch:
totalspineseg/README.md
Lines 175 to 209 in 07069b9