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

No Hippocampus Mask Available/Compatible #537

Open
naji-s opened this issue Mar 9, 2024 · 3 comments
Open

No Hippocampus Mask Available/Compatible #537

naji-s opened this issue Mar 9, 2024 · 3 comments

Comments

@naji-s
Copy link

naji-s commented Mar 9, 2024

Hi,

Thanks for all the packages that you have created for ease of processing of different imaging techniques!

I have used Clinica's t1-linear pipeline to convert my adni dataset to BIDS, and then converted my bids dataset to CAPS, which as is pointed out (here)[https://aramislab.paris.inria.fr/clinica/docs/public/latest/Pipelines/PET_Linear/] crops the final images to 169×208×179

I wanna run a model that not only uses the whole brain image but also left and right HC extractions. In clinicadl documentation however to extract left and right HC the following command is suggested:

clinicadl prepare-data CAPS_DIRECTORY t1-linear roi --roi_list rightHippocampusBox --roi_list leftHippocampusBox

The problem is no place is suggested to download these masks from. The closest thing I could come up with was
https://www.templateflow.org/browse/#:~:text=tpl%2D-,MNI152NLin2009cSym_res,-%2D1_atlas%2DCerebrA_dseg.nii

But turns out there is a size mismatch between the masks there (193,229,193), and (169,208,179).

The only way I could retrace the source code and find a way of cropping this mask was to use
(ref_cropped_template.nii.gz)[https://aramislab.paris.inria.fr/files/data/img_t1_linear/ref_cropped_template.nii.gz] based on
https://github.com/aramis-lab/clinica/blob/37da1cbbed35c5e16877e06b17074c9811a83354/clinica/pydra/t1_linear/t1_linear.py#L11

But I am not sure if I am on the right track and this cropping actually creates a compatible mask with the t1-preprocessing.
Couold you please guide me with this?

@camillebrianceau
Copy link
Collaborator

Hi @naji-s ,

Thanks for your interest in ClinicaDL,

The masks you are looking for can be downloaded here.

In the documentation, we just give an example of how the commandline works but the ROIs don't have to be the right and left hippocampus.

Don't hesitate if you have any other questions :)

@naji-s
Copy link
Author

naji-s commented Mar 12, 2024

Hi @camillebrianceau,

Thanks for fast reply! Well honestly the tutorial links to it but the link is not working, and in fact I did need the masks for left and right hippocampus so this was perfect!

Thanks so much :)

@naji-s naji-s closed this as completed Mar 12, 2024
@naji-s naji-s reopened this Mar 15, 2024
@naji-s
Copy link
Author

naji-s commented Mar 15, 2024

Hi Thanks again for your help. But I am not sure if that masks are working. I applied the masks to ADNI dataset, for one subject:

import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
import torch

# Load your MRI data into a NumPy array
hip_left = torch.load('ADNI_CAPS_DIRECTORY/subjects/sub-ADNI002S4473/ses-M024/deeplearning_prepare_data/roi_based/t1_linear/sub-ADNI002S4473_ses-M024_space-MNI152NLin2009cSym_desc-CropRoi_res-1x1x1_roi-leftHippocampusBox_T1w.pt')[0].numpy()
hip_right = torch.load('ADNI_CAPS_DIRECTORY/subjects/sub-ADNI002S4473/ses-M024/deeplearning_prepare_data/roi_based/t1_linear/sub-ADNI002S4473_ses-M024_space-MNI152NLin2009cSym_desc-CropRoi_res-1x1x1_roi-rightHippocampusBox_T1w.pt')[0].numpy()

# Function to extract points above a threshold
def extract_points(data, threshold_percentile):
    intensity_threshold = np.percentile(data, threshold_percentile)
    x, y, z = np.where(data > intensity_threshold)
    intensity = data[x, y, z]
    return x, y, z, intensity

# Prepare subplot figure with 2 3D subplots
fig = make_subplots(rows=1, cols=2, specs=[[{'type': 'scatter3d'}, {'type': 'scatter3d'}]])

# Left hippocampus
x, y, z, intensity = extract_points(hip_left, 80)  # Adjust percentile as needed
fig.add_trace(go.Scatter3d(x=x, y=y, z=z, mode='markers', marker=dict(size=2, color=intensity, colorscale='Viridis', opacity=0.5)), row=1, col=1)

# Right hippocampus
x, y, z, intensity = extract_points(hip_right, 80)  # Adjust percentile as needed
fig.add_trace(go.Scatter3d(x=x, y=y, z=z, mode='markers', marker=dict(size=2, color=intensity, colorscale='Viridis', opacity=0.5)), row=1, col=2)

# Update layout for better visualization
fig.update_layout(height=600, width=1200, title_text="Left and Right Hippocampus 3D Visualization")
fig.show()

I am not sure if the patches I am seeing are accurate?
image

Also any particular reason that these patches are automatically set to (50, 50, 50) size?

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

2 participants