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

Tissue class mapping wrong with T2w inputs #1171

Open
mharms opened this issue Jan 7, 2024 · 7 comments
Open

Tissue class mapping wrong with T2w inputs #1171

mharms opened this issue Jan 7, 2024 · 7 comments
Labels

Comments

@mharms
Copy link

mharms commented Jan 7, 2024

The following is based on my experience with running T2w anatomical scans through version 22.0.6, but looking through the current code in the master branch, I don't see any reason to expect that it wouldn't be an ongoing problem with the current version.

This line of code
https://github.com/nipreps/mriqc/blob/24f786ae9e312b55830139e354627e837ea5703a/mriqc/qc/anatomical.py#L213C1-L213C16
defines the following mapping between the tissue labels used in MRIQC and the FAST segmentation labels:
FSL_FAST_LABELS = {"csf": 1, "gm": 2, "wm": 3, "bg": 0}

That mapping is indeed correct for T1w anatomicals. But at least in our T2w data, the typical segmentation that we are getting out of FAST (as launched by the MRIQC default settings) has GM = 1, WM = 2, and CSF = 3. But MRIQC doesn't appear to account for that altered mapping for T2w data.

The end result is that any MRIQC metric that is dependent on the T2w segmentation is either mislabeled, or just wrong (e.g., CJV and CNR are intended to be based on GM and WM, but per above what MRIQC is labeling "wm" is typically actually CSF, and what it is labeling "gm" is typically actually WM, in the case of T2w data).

@WilliamFCB
Copy link

@effigies and other MRIQC developers, as I am also running mriqc on T2 data, it would be great to hear feedback on this issue raised by @mharms
Many thanks in advance!

@mharms
Copy link
Author

mharms commented Jan 16, 2024

@WilliamFCB : When you look at the actual segmentation maps, are you seeing the same thing that I'm reporting above?

@effigies
Copy link
Member

#1099 switched to Atropos, and was included in 23.1.0, but I believe it does the same thing of simply ordering tissues by mean intensity.

It looks like fixing this will be non-trivial, as T1w assumptions are baked into the workflow, and then all anatomical images are passed with no additional parameterization:

dataset = config.workflow.inputs.get("t1w", []) + config.workflow.inputs.get("t2w", [])
message = BUILDING_WORKFLOW.format(
modality="anatomical",
detail=(
f"for {len(dataset)} NIfTI files."
if len(dataset) > 2
else f"({' and '.join(('<%s>' % v for v in dataset))})."
),
)
config.loggers.workflow.info(message)
# Initialize workflow
workflow = pe.Workflow(name=name)
# Define workflow, inputs and outputs
# 0. Get data
inputnode = pe.Node(niu.IdentityInterface(fields=["in_file"]), name="inputnode")
inputnode.iterables = [("in_file", dataset)]

It shouldn't be a terribly difficult job, though. The fix seems to me be adding a contrast weighting input to the iterable (using synchronization to keep the variables paired), and pass it as an input to any subworkflows that need to adjust their behavior based on the weighting.

Are there other effects that you're seeing, or is it simply that we need to select an alternative tissue mapping for T2w images?

@WilliamFCB
Copy link

@mharms, I did not really look before I posted. I just saw your post and thought it deserved a response.

Anyway, having said that, I just located the T2 segmentation files and had a look.
I get 1= CSF, 2= GM and 3=WM. So, that follows the T1 format.
I used mriqc.23.1.0 by the way.

Cheers William

@mharms
Copy link
Author

mharms commented Jan 17, 2024

So, if I understand correctly, you aren't seeing any problems with the segmentation of your T2w data using 23.1.0? Is 23.1.0 still using FAST, or is it using ANTS? What type of T2-weighted scan are you collecting? e.g., Is CSF bright or dark (FLAIR)?

Could you maybe post a snapshot of what you are seeing for a typical segmentation? I've attached an example of the segmentation labels that we are typically getting in our CSF bright T2w scans. (In a small number of cases, we are getting WM coded as 3 from FAST.)
Screenshot 2024-01-17 at 9 30 10 AM

@mharms
Copy link
Author

mharms commented Jan 17, 2024

#1099 switched to Atropos, and was included in 23.1.0, but I believe it does the same thing of simply ordering tissues by mean intensity.

Ordering by intensity would have WM < GM in a T2w scan, so if Atropos is assigning numeric segmentation labels consistent with the ordering in a T1w scan, it wouldn't be ordering by intensity.

@WilliamFCB
Copy link

Attached are a few snapshots. The T2's are not usable because of gibs ringing artefacts. This has the effect that CSF is not always bright. Anyway, I ran mriqc because I was interested to see the QC measures mriqc calculates in this case.
Screenshot 2024-01-17 at 20 52 19
Screenshot 2024-01-17 at 20 52 38
Screenshot 2024-01-17 at 20 48 20
Screenshot 2024-01-17 at 20 48 42

@oesteban oesteban added the bug label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants