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

add qc_views #17

Open
edickie opened this issue Jul 29, 2022 · 0 comments
Open

add qc_views #17

edickie opened this issue Jul 29, 2022 · 0 comments

Comments

@edickie
Copy link
Contributor

edickie commented Jul 29, 2022

Here's some code I hacked together last night to start creating qc images...

import pandas as pd
from nilearn import plotting
​
​
# In[3]:
​
​
subjects = pd.read_csv('/KIMEL/tigrlab/scratch/mjoseph/bids/TAY/code/subject_list.txt', header = None)
​
​
# In[29]:
​
​
PLOT_DIR=f"/KIMEL/tigrlab/scratch/edickie/TAY_DWI_QA/" 
​
​
# In[31]:
​
​
get_ipython().system(' mkdir -p {PLOT_DIR}')
get_ipython().system(' mkdir {PLOT_DIR}/ICVF')
get_ipython().system(' mkdir {PLOT_DIR}/ICVF_GM')
get_ipython().system(' mkdir {PLOT_DIR}/ICVF_WM')
get_ipython().system(' mkdir {PLOT_DIR}/ISOVF')
get_ipython().system(' mkdir {PLOT_DIR}/ISOVF_GM')
get_ipython().system(' mkdir {PLOT_DIR}/ISOVF_WM')
get_ipython().system(' mkdir {PLOT_DIR}/OD')
get_ipython().system(' mkdir {PLOT_DIR}/OD_GM')
get_ipython().system(' mkdir {PLOT_DIR}/OD_WM')
​
​
# In[42]:
​
​
from pathlib import Path# subject = subjects.loc[0,0]
​
​
for subject in subjects.loc[:,0].to_list():
    
    AMICO_RESAMPLED_DIR=f"/KIMEL/tigrlab/scratch/fogunsanya/dmri-microstructure/amico_resampled_MNI152NLin6/{subject}/ses-01/dwi"
    FMRIPREP_DIR=f"/KIMEL/tigrlab/archive/data/TAY/pipelines/in_progress/baseline/fmriprep/{subject}/ses-01/anat"
    OUTPUT_DIR=f"/KIMEL/tigrlab/scratch/fogunsanya/dmri-microstructure/NODDI_volume_space_masked/{subject}/ses-01/dwi" 
    
    print(subject)
​
    for noddi_type in ["ICVF", "ISOVF", "OD"]:
        noddi_img = f"{AMICO_RESAMPLED_DIR}/{subject}_ses-01_space-MNI152NLin6Asym_desc-{noddi_type}_NODDI.nii.gz"
        
        if Path(noddi_img).is_file():
            
            p1 = plotting.plot_img(noddi_img, cut_coords=[-26, -27, 0], title = f"{subject} {noddi_type}", colorbar = True)
            p1.savefig(f"{PLOT_DIR}/{noddi_type}/{subject}_{noddi_type}.png")
​
            for mask_type in ["GM","WM"]:
                mask = f"{FMRIPREP_DIR}/{subject}_ses-01_space-MNI152NLin6Asym_label-{mask_type}_probseg.nii.gz"fig = plotting.plot_anat(noddi_img, cut_coords=[-26, -27, 0], title = f"{subject} {noddi_type} {mask_type}")
                fig.add_contours(mask, filled = True, levels=[.6], alpha = 0.4, colors='y')
                fig.savefig(f"{PLOT_DIR}/{noddi_type}_{mask_type}/{subject}_{noddi_type}_{mask_type}.png")
        else: 
            print(f"{noddi_img} is missing")
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

1 participant