Last active
June 9, 2020 13:18
-
-
Save xgrg/f7ecd8288dc94767bd24b7ebf435b35e to your computer and use it in GitHub Desktop.
Nisnap SPM_SEGMENT (Carles/Jordi)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyxnat | |
from nisnap import xnat, snap | |
from glob import glob | |
import os.path as op | |
methods = ['T1', 'T1_FLAIR', 'T1_T2', 'T1_maskT1T2'] | |
x = pyxnat.Interface(config='/home/grg/.xnat_goperto_ci.cfg') | |
dd = '/mnt/projects/Segmentation_ALFA_PLUS_IRENE' | |
subjects2 = sorted([int(e.split('/')[-1]) for e in glob(op.join(dd, 'segmentacions_T1', '*'))]) | |
subjects = sorted([int(e['subject_label']) for e in x.array.experiments(project_id='ALFA_PLUS', | |
columns=['subject_label'])]) | |
subjects = sorted(set(subjects2).intersection(subjects)) | |
experiments = [] | |
for e in subjects: | |
exp = x.array.experiments(subject_label=e, project_id='ALFA_PLUS').data[0]['ID'] | |
experiments.append((e, exp)) | |
d = {'SPM12_SEGMENT_T2T1_COREG3': 'T2T1_COREG3', | |
'SPM12_SEGMENT_COREG' : 'T1_COREG', | |
'SPM12_SEGMENT_T2T1_COREG6': 'T2T1_G33342', | |
'SPM12_SEGMENT_T2T1_COREG7': 'T2T1_G33342_no_denoising', | |
'SPM12_SEGMENT_T2T1_COREG8': 'T2T1_COREG3_no_denoising'} | |
carles = True | |
jordi = True | |
for i, (s, e) in enumerate(experiments[25:]): | |
print(i, s,e) | |
if jordi: | |
for k, v in d.items(): | |
xnat.plot_segment('/home/grg/.xnat_goperto_ci.cfg', experiment_id=e, axes='x', | |
opacity=40, slices=list(range(139,197,3)), rowsize=5, figsize=(10,10), | |
resource_name=k, savefig='/tmp/snapshots/%s_%s.png'%(s, v), animated=False, cache=False) | |
if carles: | |
for m in methods: | |
cfiles = sorted(glob(op.join(dd, 'segmentacions_%s'%m, str(s), 'c*T1_ALFA1_%s.nii'%s))) | |
t1 = glob(op.join(dd, 'T1', str(s), 'T1_ALFA1_%s.nii'%s))[0] | |
print(t1, cfiles) | |
snap.plot_segment(cfiles, bg=t1, axes='x', savefig='/tmp/snapshots/%s_%s.png'%(s, m), | |
slices=list(range(139,197,3)), rowsize=5, opacity=40, figsize=(10,10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment