Skip to content
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

pyAFQ pipeline: Use previous analysis derivatives as inputs for masks: seed and brain. #571

Closed
wants to merge 3 commits into from

Conversation

arokem
Copy link
Contributor

@arokem arokem commented May 12, 2023

Changes proposed in this pull request

This changes the defaults for seed mask and brain mask for the pyAFQ pipeline, using pyAFQ's mask definition API.

Might resolve #563

@arokem arokem changed the title Use previous analysis derivatives as inputs for masks: seed and brain. pyAFQ pipeline: Use previous analysis derivatives as inputs for masks: seed and brain. May 12, 2023
@36000
Copy link
Contributor

36000 commented May 12, 2023

@@ -16,7 +16,7 @@
"directions": "prob",
"max_angle": 30.0,
"sphere": "",
"seed_mask": "",
"seed_mask": "ImageFile('suffix': 'WM', {'scope': 'qsiprep', 'space': None})",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @36000 : should this use an ImageFile or a MaskFile object? Would this work as written here? That is, do these names (ImageFile, MaskFile) exist in the namespace in which this config is run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, can anyone tell me how mrtrix pipelines choose where to place seeds? In particular, the msmt_noACT pipeline?

@@ -79,6 +79,7 @@ def init_pyafq_wf(omp_nthreads, available_anatomical_data,
('bval_file', 'bval_file'),
('bvec_file', 'bvec_file'),
('dwi_mask', 'mask_file'),
('wm_mask', 'wm_mask_file'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattcieslak : what should we put here for wm_mask?

@arokem
Copy link
Contributor Author

arokem commented May 12, 2023

Updated (with help from @36000, thank you!) to do this the right way. The config is now explicit about using the WM_prob output to avoid confusion (it turns out that I was wrong in #563, because the default settings use FA with 0.2 as a threshold, but that logic is a bit hidden in pyAFQ, which we will also fix separately...), and a probability of 0.5 as the threshold.

@mattcieslak
Copy link
Collaborator

I think some of the recent changes in the anatomical workflow are causing some of the data AFQ previously used to not be present anymore. I'm definitely open to suggestions on a best default behavior here, but I really like the idea of using a low FA threshold instead of an anatomically defined WM mask. This is because the anatomical masks are unreliable because they can come from a couple sources.

  • If 0.17 or earlier is used there may be a 3-tissue dseg and a probseg from FAST. These are almost always bad.
  • QSIPrep After 0.17 will have a 3-tissue dseg from SynthSeg. These are usually excellent, but it's still a new method and I have seen some bad failures with it.
  • For recon-only you may have a great segmentation from non-synth FreeSurfer available. This is also just a deterministic segmentation, though.
  • If the user ran a --dwi-only you have a mask based only on a mostly reliable b=0 masking method.

Also if the user doesn't have fieldmaps available the t1w or t2w-based tissue masks won't align well with the processed dwi data.

For the mrtrix hsvs we require a freesurfer segmentation, which guarantees good results as long as susceptibility distortion was run. We could impose a requirement that a good anatomical segmentation from freesurfer is available if the user wants to use it for AFQ. It seems simpler and (if no fieldmap is available) more effective to use a FA mask.

What do you think?

@tsalo
Copy link
Member

tsalo commented Nov 19, 2024

Is this something we should reproduce in QSIRecon?

@arokem
Copy link
Contributor Author

arokem commented Nov 19, 2024

Yes, that would be great. We routinely do this kind of thing when we run pyAFQ on top of qsiprep derivatives, and it's beneficial. The default for brain-masking in pyAFQ, in particular, is quite poor as it relies on the (not very good) median Otsu algorithm for brain extraction.

@tsalo
Copy link
Member

tsalo commented Nov 19, 2024

I've opened PennLINC/qsirecon#170 to track this in QSIRecon. I'll close this PR since there's no way to merge it in QSIPrep but I have a link to it from the QSIRecon issue so someone can copy over the changes to their own branch at some point.

@tsalo tsalo closed this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pyAFQ pipeline uses 0 FA as seed threshold?
4 participants