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
Added an option for keypoints transformation #2533
Conversation
…n to perform because the input file contains point like label. It seems fonctionnal but is still a work in progress. The transformed file overwrite the first created one. the option is here activated by default but an accepted argument
…ts. removing extra lines as well
…n question about where to save the actual straight file before using cubic to points.
…mage (before applying cubic to point)
…ate the dilatation and nearest neighbors interpolation.
scripts/sct_apply_transfo.py
Outdated
@@ -19,10 +19,12 @@ | |||
import sys, io, os, time, functools | |||
import argparse | |||
|
|||
|
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.
only single line separation
see: https://github.com/neuropoly/spinalcordtoolbox/wiki/example_script
scripts/sct_apply_transfo.py
Outdated
from spinalcordtoolbox.utils import Metavar, SmartFormatter | ||
from spinalcordtoolbox.image import Image | ||
from spinalcordtoolbox.cropping import ImageCropper | ||
|
||
|
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.
single line
scripts/sct_apply_transfo.py
Outdated
@@ -120,7 +128,7 @@ def get_parser(): | |||
|
|||
|
|||
class Transform: | |||
def __init__(self, input_filename, fname_dest, list_warp, list_warpinv=[], output_filename='', verbose=0, crop=0, | |||
def __init__(self, input_filename, fname_dest, list_warp, list_warpinv=[], output_filename='', verbose=0, crop=0,label=0, |
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.
space after comma-- PEP8
scripts/sct_apply_transfo.py
Outdated
@@ -132,7 +140,8 @@ def __init__(self, input_filename, fname_dest, list_warp, list_warpinv=[], outpu | |||
self.verbose = verbose | |||
self.remove_temp_files = remove_temp_files | |||
self.debug = debug | |||
|
|||
self.label=label |
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.
space between =.
PEP8
scripts/sct_apply_transfo.py
Outdated
@@ -142,6 +151,9 @@ def apply(self): | |||
verbose = self.verbose | |||
remove_temp_files = self.remove_temp_files | |||
crop_reference = self.crop # if = 1, put 0 everywhere around warping field, if = 2, real crop | |||
label=self.label |
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.
space. Please apply PEP8 for all your modifs (there are other formatting issues below)
scripts/sct_apply_transfo.py
Outdated
tmp_src=os.path.join(path_tmp, "dilated_data.nii") | ||
tmp_out=os.path.join(path_tmp, "dilated_data_reg.nii") | ||
|
||
sct.run(['isct_antsApplyTransforms', |
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.
duplicated code (see below)
@lrouhier after giving it some thoughts, how about adding a possible value |
Maybe it will be clearer! It does not change much in the code for me and i think it's easier for the user. Any thoughts on how to explain it in the help? for now I wrote : |
i would go with:
|
- Added verbose - Added ImplementationError for dim=4 case
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.
Great contribution! 👍
Let's merge #2522 before this one |
* First implementation of a -label option that specify certain operation to perform because the input file contains point like label. It seems fonctionnal but is still a work in progress. The transformed file overwrite the first created one. the option is here activated by default but an accepted argument * forget to change a parameter. which causes it to not label every points. removing extra lines as well * refactoring with precisting sct function. everything look smooth. open question about where to save the actual straight file before using cubic to points. * force the nearest neighbors interpolation when using the -label flag. * added creation of tmp folder to stor dilated and straighten dilated image (before applying cubic to point) * Added the removal of temporary files (if not stated otherwise) * removing lines. PEP-8 normalization * remove extra lines * refactor parser. the -label flag does not need any argument and activate the dilatation and nearest neighbors interpolation. * PEP-8 formatting * remove duplicated code * put -label flag as an interpolation option. * changing help discription for -x flag * removing extra lines * rmoving extra line and defining label in the case that the flag is not used. * sct_apply_transfo: Updated usage * sct_apply_transfo: Minor refactoring - Added verbose - Added ImplementationError for dim=4 case Former-commit-id: f89d6cb
This PR aims to add the -label flag to the sct_apply_transfo script. This flag can be used when applying a warping field to images containing point-like labels (e.g., discs label).
It performs the following :
Fixes #2519