Skip to content

edited documentation 5ttgen hsvs -white_stem#2330

Closed
nicdc wants to merge 21 commits intoMRtrix3:masterfrom
nicdc:master
Closed

edited documentation 5ttgen hsvs -white_stem#2330
nicdc wants to merge 21 commits intoMRtrix3:masterfrom
nicdc:master

Conversation

@nicdc
Copy link
Contributor

@nicdc nicdc commented Jun 1, 2021

Please enter a concise description of the changes proposed in the pull request,
along with any relevant links to external discussions.

  • If your pull request involves fixing a bug, then the relevant code
    should be in a branch that is a derivative of master, and you should
    select master as the target branch in the pull request; for all other
    pull requests, the relevant code should be in a branch that is a
    derivative of dev, and you should select dev as the target branch
    of the pull request (assuming no other more appropriate branch exists).

  • If your proposed changes address an existing Issue
    listed on GitHub, please add a reference to that Issue (a "#"
    character followed by the issue number).

  • If your proposed changes are not yet ready to be merged, but you are
    creating a pull request in order to initiate communications on such,
    please flag it as a draft pull request.

  • You may optionally add @mentions of a person or team appropriate
    for reviewing proposed changes.
    @Lestropie

@nicdc
Copy link
Contributor Author

nicdc commented Jun 24, 2021

Detailed changes:

  1. documentation for -white_stem option extended so that users are aware of the consequence of using this option on ACT
  2. labelconvert files for Schaefer 2018 local - global parcellations added to share/mrtrix
  3. Added -first_dir option to three scripts (labelsgmfix, 5ttgen fsl and 5ttgen hsvs). If users provide the path to this folder, the script will copy these files into the scratch directory rather than run the registration and segmentation again
  4. Added -fast_dir option to 5ttgen fsl script, as this output was already available from anatomical preprocessing.
  5. Documentation added to these three scripts about expected filenames and image space considerations for the first_dir and fast_dir options.

I ran this on my own data and it works as expected. There is still room for optimization - was not sure how to include wildcards in the fsl.find_image call to handle data with different prefixes etc.

Would be happy to have some feedback (@jdtournier @Lestropie )

Cheers,
Nick

@Lestropie
Copy link
Member

Hi @nicdc,

Sorry for taking forever to comment on this; I'm way behind on a lot of things right now...
(I actually just started writing this as you posted; honest!)

It looks like the scope of the contents of the PR have increased a bit since it was first listed, which means the title no longer describes the scope of changes. You or I can edit the PR title accordingly, or it can be split into multiple distinct PRs, each with its own distinct purpose. The latter tends to be better for tracking from a software engineering perspective, though it's hard for me to demand such if I'm not responding to them promptly... 🤦 The addition of the parcellation LUTs is however sufficiently distinct from 5ttgen that I think it should be in a separate PR.

I'll add other comments to the relevant code snippets.

Cheers
Rob

- **-premasked** Indicate that brain masking has already been applied to the input image

- **-first_dir /path/to/first/dir** use output of FSL FIRST if it has been previously run on input T1-weighted image, in the SAME SPACE as input T1
- **-first_dir /path/to/first/dir** use output of FSL FIRST if it has been previously run on input T1-weighted image, in the SAME SPACE as input T1. Filename prefix should be first-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason why one would be using a capability such as this is if it is intended for these data to be used in multiple subsequent pipelines; demanding a specific naming convention may undermine such. What would be preferable would be:

  1. Query the contents of the filesystem directory;
  2. Search for prefix strings for which all of the requisite file names are present;
  3. Proceed if the number of such unique prefixes is 1.

Comment on lines +114 to +115
run.command('cp ' + path.from_user(vtk_in_path) + ' ' + path.to_scratch(vtk_in_path))
run.command('cp -r ' + path.from_user('first.logs') + ' ' + path.to_scratch('first.logs'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the shutil module (via run.function()) is preferable to run.command(cp ...).

options.add_argument('-premasked', action='store_true', help='Indicate that brain masking has already been applied to the input image')
options.add_argument('-first_dir', metavar='/path/to/first/dir', help='use output of FSL FIRST if it has been previously run on input T1-weighted image, in the SAME SPACE as input T1')
options.add_argument('-first_dir', metavar='/path/to/first/dir', help='use output of FSL FIRST if it has been previously run on input T1-weighted image, in the SAME SPACE as input T1. Filename prefix should be first-')
options.add_argument('-fast_dir', metavar='/path/to/fast/dir', help='use output of FSL FAST if it has been previously run on input T1-weighted image, in the SAME SPACE as input T1. Filename prefix should be T1_BET')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as prior comment RE: file prefix

if not os.path.isdir(os.path.abspath(app.ARGS.fast_dir)):
raise MRtrixError('FAST directory cannot be found, please check path')
fast_output_prefix = fast_t1_input.split('.')[0]
fast_csf_input = fast_output_prefix + 'pve_0.nii.gz'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an underscore missing here?

@Lestropie
Copy link
Member

In addition, we're trying to be a bit more comprehensive with testing; execution times can be prohibitive for testing of Python scripts, but we do nevertheless try to implement tests for Python scripts that can be executed manually prior to tag releases. The whole git submodule thing can be very temperamental, so I can help in adding some tests there.

@Lestropie
Copy link
Member

... was not sure how to include wildcards in the fsl.find_image call to handle data with different prefixes etc.

For files with different prefixes, it'd just be a matter of running the function once for each prefix. The function is only there because there are specific instances in which relying on an e.g. .nii.gz extension will result in an error because the images were saved uncompressed, and it's not 100% predictable.

You can also be clever in instances like this with list comprehensions; e.g.:

fast_inputs = [fsl.find_image(fast_output_prefix + '_pve_' + postfix) for postfix in ['0', '1', '2']]
if any(entry is None for entry in fast_inputs):
  raise MRtrixError(...)

@jdtournier
Copy link
Member

I might add that some of these changes (documentation updates) can go straight to master (for inclusion into 3.0.3), but the rest of the changes seem to modify behaviour or constitute enhancements (not bug fixes), so really should be included in one (or more) separate PR to the dev branch (for inclusion into 3.1.0).

Apologies if this is a bit of a pain, but we're trying to stick to a predictable release pattern - something we've not been very good at in the past, which has at times caused some frustration with users.

@Lestropie Lestropie added this to the 3.0.5 updates milestone Sep 16, 2024
@Lestropie
Copy link
Member

Added to 3.0.5 milestone, but will need to cherry-pick the content that is suitable for master.

@Lestropie Lestropie self-assigned this Nov 20, 2024
Lestropie pushed a commit that referenced this pull request Nov 23, 2024
Lestropie pushed a commit that referenced this pull request Nov 24, 2024
Manual application of changes in #2330 by: Robert E. Smith <[email protected]>
@Lestropie Lestropie mentioned this pull request Nov 24, 2024
5 tasks
@Lestropie
Copy link
Member

Closing as content has been separated out into topics with dedicated PRs.

@Lestropie Lestropie closed this Nov 24, 2024
Lestropie pushed a commit that referenced this pull request Aug 26, 2025
Manual application of changes in #2330 by: Robert E. Smith <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants