-
Notifications
You must be signed in to change notification settings - Fork 4
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
Removal of hard-coded configuration
file in preprocess_segment.sh
script and extraction of include_list
from the configuration
file directly
#75
Conversation
configuration
file in preprocess_segment.sh
script and extraction of include_list
from the configuration
file directly
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.
What you've done here looks good to me! 🎉
However, I had an additional idea that might make this even simpler:
-
I notice that you are forced to parse the extra keys from
configuration.json
yourself:
template/preprocess_segment.sh
Lines 55 to 58 in a5d1402
PATH_DATA=$(echo "$json_data" | sed -n 's/.*"path_data": "\(.*\)".*/\1/p') DATA_TYPE=$(echo "$json_data" | sed -n 's/.*"data_type": "\(.*\)".*/\1/p') IMAGE_SUFFIX=$(echo "$json_data" | sed -n 's/.*"suffix_image": "\(.*\)".*/\1/p') CONTRAST=$(echo "$json_data" | sed -n 's/.*"contrast": "\(.*\)".*/\1/p') -
This is awkward! But, I realize that it is necessary, because
sct_run_batch
ignores any "extra config keys" that do not match the originalsct_run_batch
arguments. -
However, I thought of an alternative. You could write your
configuration.json
to usescript_args
directly:{ "path_data": "/path/to/data/", "include_list": "sub-001 sub-002 sub-003", "#": "Args below: $DATA_TYPE, $CONTRAST, $IMAGE_SUFFIX, $LAST_DISC (parsed in script)" "script_args": ["anat", "t1", "_T1w", "26"] }
Then, these arguments can be retrieved directly using
$2
,$3
, etc., which removes the need to pass the configuration file twice, and removes the need to manually parse the configuration file.The only issue with this is that json files do not support comments. So, I added a "fake comment" to document what each of the "script_args" means. But maybe this is confusing? (Note: YAML does support comments, so that might be an option as well.)
If this is worse, then of course we can just keep the original way of doing this, too (since the json file is clearer as-is, I think).
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.
Thank you for responding to my feedback! LGTM, I think this is good to merge. :)
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.
👍
This PR solves the issues #72 and #73
What this PR solves:
preprocess_segment.sh
, theconfiguration.json
file was hard-coded which meant whatever we pass as a value the-config
flag, it will read only theconfiguration.json
from the script. This PR takes theconfiguration.json
from thesct_run_batch
command rather than a hard-coded value.--include-list
while running thepreprocessing.sh
usingsct_run_batch
even when the values are already mentioned in theinclude-list
in theconfiguration.json
. This PR helps thesct_run_batch
to take this value directly from theconfiguration.json
file.Steps to reproduce this PR:
Data:
duke/temp/rohan/bids_data
Config file values:
Run the
preprocess_segment.sh
using thesct_run_batch
from theREADME
of this PR.Expected output
Running this script should create a temporary output folder with the
segmentation
anddisc_level
derivatives with the names:{SUBJECT_NAME_CONTRAST}_label-SC_mask.nii.gz
{SUBJECT_NAME_CONTRAST}_labeled-discs.nii.gz