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

Weird Artifacts in Masks #1

Open
Govish opened this issue Sep 19, 2024 · 5 comments
Open

Weird Artifacts in Masks #1

Govish opened this issue Sep 19, 2024 · 5 comments

Comments

@Govish
Copy link

Govish commented Sep 19, 2024

Hi guys, hope you're doing well!

We've been running into some issues with some artifacts in the mask--there seem to be some rough edges/bleeding that may not be accurately capturing only the target anatomy. The image you hopefully see below shows this detail on fieldmap_3.

image

We've been able to work around this issue by eroding the masks by 3-4 voxels, but a root-cause fix would be much appreciated. It's had been noticeably impacting the performance of the optimizer and validity of the results.

Thanks!
-Ishaan

@jcohenadad
Copy link
Member

@Govish sorry for the slow reply. Just to be sure: are you talking about the fieldmaps produced by our team and sent by @CharlesPageot within the context of our collaboration? If so, I would not use this repository to discuss that project. This repository is specifically about the susceptibility-to-fieldmap software. We should start a new repos (in this organization) and transfer this issue. In the meantime, @CharlesPageot can you please assist @Govish?

@Govish
Copy link
Author

Govish commented Oct 8, 2024

Yeah--I'm referring to the field maps sent over in the scope of our specific collaboration; and sounds good! Let me know where would be a good place to discuss this!
However, I think this issue may be a bit more general than our specific collaboration—I’m not sure if some of these masking issues may persist with other field maps.
Thanks!

@jcohenadad jcohenadad transferred this issue from shimming-toolbox/susceptibility-to-fieldmap-fft Oct 10, 2024
@jcohenadad
Copy link
Member

jcohenadad commented Oct 10, 2024

@CharlesPageot will write up a procedure to address this issue, but briefly:

  • @CharlesPageot share the source data (ie: masks output from TotalSeg) with @jcohenadad. Currently, data were sent as one package via onedrive. Approximate size: 5GB. @jcohenadad will put the data on OpenNeuro.
  • @CharlesPageot share code used to apply batch processing of: (i) mask to susceptibility (ii) susceptbility to fieldmap
  • @CharlesPageot describe procedure (on 3D slicer-- although not ideal bc not easily batchabe-- ideally: solution using CLI method, eg from FSL, ANTs, etc. for the purpose of smoothing 3D binary masks), and @jcohenadad review procedure
  • @Govish fill up the README with description of the purpose, and location of the data so we can all contribute
  • @Govish once procedure for smoothing mask is done, apply it and give feedback directly in this issue (screenshots, etc.)

@CharlesPageot
Copy link

@jcohenadad @Govish

Procedure to generate the fieldmaps based on inital segmentation

Here I describe the steps to generate the fieldmaps, once each subject as a corresponding NIfTI file with every label of interset.

I uploaded a code in a new branch which is a batch procedure that calls both of those tools to generate the fieldmaps. Before running the script, one should create a new environment and follow the installation instruction from the two repos.

Procedure to generate the spine and brain masks

Here I describe the steps I used to generate the 3D binary masks for the brain and spine. I added steps (that were not yet implemented) to crop the spine mask to only the C-spine (see #2)

C-spine mask

My idea to generate C-spine mask was to use the vertebrae labels from TotalSpineSeg to find the right position to crop. From the documentation, we know that segment 17 correspond to the C7 vertebrae.

image

So the steps would be:

  • Open the spine labels (vertebrae and discs) and find the position of the lowermost pixel corresponding to C7 (segment 17)
  • Get the spinal canal label (spinal cord + CSF) and set every pixel lower than previously found position to zero.

Brain mask

Here are the problematic masks. What I have done previously was to combine every brain labels + CSF of the SAMSEG output to generate the masks. We can see below where the artifacts come from; the CSF is noisy, it overlaps with the skull and bleed inside the frontal sinuses.

image

Here it might be good to look into other method to create brain masks as @jcohenadad pointed (FSL, ANTs, etc.) because smoothing operation tends to accentuate the overlap with the skull as we will see in the next section.

Combine the masks

Once I had the spine and the brain masks, I perform a combination of the labels and a smoothing on Slicer. The smoothing was to connect the top of the cervical spine with the brain to have a continuous mask. I added a Python script which automate this procedure on Slicer.

image

We see here that this operation correctly connect the two masks, but the smoothing generate unwanted overlap with the skull due to poo brain masks.

@jcohenadad
Copy link
Member

@mathieuboudreau 👆

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

No branches or pull requests

3 participants