# set subjects_dir subjects_dir = os.path.join(script_dir, 'subjects') # set template directory template_dir = os.path.join(script_dir, 'anat_templates') # APPEND TO PYHTONPATH prep_script_dir = os.path.join(script_dir, 'preprocessing') plots_script_dir = os.path.join(script_dir, 'plots') sys.path.extend([prep_script_dir, plots_script_dir]) # GET SUBJECT LIST FROM TXT FILE full_subjects_list = load_subjects_list(subjects_dir, subjects_file) # reduce subjects list to fold subjects_list = get_subjects_list_fold(full_subjects_list, fold_n, fold_size) # check pandas version import pandas as pd print('Using pandas version %s' % pd.__version__) if LooseVersion(pd.__version__) >= '0.16': print('pandas version OK') else: raise Exception('pandas version >= 0.16 required') fsl_v_str = subprocess.check_output('cat $FSLDIR/etc/fslversion', shell=True).strip()
import os, glob, datetime import json from variables import freesurfer_dir, subjects_dir from utils import load_subjects_list dicom_dir = '/scr/kaiser2/NKI/nki_r5_onwards/r6_onwards/dicoms/all_studies_V2' os.chdir(dicom_dir) previous_subjects_file = 'subjects_2015-09-04_r5_r6_r7.txt' previous_subjects = load_subjects_list(subjects_dir, previous_subjects_file) subjects_list = [s for s in glob.iglob('A*')] #dicom_dict = {'t1w':'anat', 'rs':'session_1/RfMRI_mx_645', 'diffusion':'session_1/DTI_mx_137'} # r8 schema dicom_dict = {'t1w':'MPRAGE_SIEMENS_DEFACED*', 'rs':'REST_645_*', 'diffusion':'DIFF_137_AP_*'} dicom_missing = {'t1w':[], 'rs':[], 'diffusion':[], 'fs':[]} bad_subjects_list = [] for subject in subjects_list: for img, img_file in dicom_dict.items(): check_file = os.path.join(dicom_dir, subject, '*', img_file) file_exists = glob.glob(check_file) if len(file_exists)==0: print ('NOOOK: %s %s does not exist'%(subject, img)) dicom_missing[img].append(subject) if not subject in bad_subjects_list: bad_subjects_list.append(subject)
# set subjects_dir subjects_dir = os.path.join(script_dir, 'subjects') # set template directory template_dir = os.path.join(script_dir, 'anat_templates') # APPEND TO PYHTONPATH prep_script_dir = os.path.join(script_dir, 'preprocessing') plots_script_dir = os.path.join(script_dir, 'plots') sys.path.extend([prep_script_dir, plots_script_dir]) # GET SUBJECT LIST FROM TXT FILE full_subjects_list = load_subjects_list(subjects_dir, subjects_file) # reduce subjects list to fold subjects_list = get_subjects_list_fold(full_subjects_list, fold_n, fold_size) #check CPAC version print('Using CPAC version %s' % CPAC.__version__) if LooseVersion(CPAC.__version__) >= '0.3.9.1': print('CPAC version OK') else: raise Exception('CPAC version >= 0.3.9.1 required') #check pandas version import pandas as pd print('Using pandas version %s' % pd.__version__)
script_dir = os.path.dirname(os.path.realpath(__file__)) template_dir = os.path.join(script_dir, 'templates') wd_root_path = '/data/liem-3/LIFE/' metrics_root_path = '/scr/adenauer2/Franz/LeiCA_LIFE/' ds_root_path = '/scr/adenauer2/Franz/LeiCA_LIFE' subjects_list_folder = '/home/raid2/liem/data/LIFE/behavioral' subject_file = '/scr/adenauer2/Franz/LIFE16/LIFE16_preprocessed_subjects_list_n2557.txt' behav_file = '/home/raid2/liem/data/LIFE/behavioral/LIFE_subjects_behav_n2615.pkl' qc_file = '/home/raid2/liem/data/LIFE/behavioral/LIFE_subjects_QC_n2557.pkl' subjects_list = load_subjects_list(subject_file) in_data_root_path = '/data/liem-1/LIFE/preprocessed' selectfiles_templates = { 'epi_MNI_bp': '{subject_id}/resting_state/ants/rest_mni_unsmoothed.nii.gz', 'epi_MNI_fullspectrum': '{subject_id}/resting_state/ants/rest_mni_unsmoothed_fullspectrum.nii.gz', 'moco_parms_file': '{subject_id}/resting_state/realign/rest_realigned.par', 'jenkinson_file': '{subject_id}/resting_state/realign/rest_realigned_rel.rms', 'rest2anat_cost_file': '{subject_id}/resting_state/coregister/rest2anat.dat.mincost', }
from qc_reports.create_qc_report_pdf import create_qc_report_pdf from variables import ds_dir, report_base_dir, subjects_dir from variables import TR_list, full_subjects_list, subjects_file_prefix from variables import plugin_name, use_n_procs #fixme full_subjects_list.remove('A00056097') #fixme plugin_name = 'MultiProc' use_n_procs = 25 subjects_list = full_subjects_list subjects_missing_files_list = load_subjects_list(subjects_dir, subjects_file_prefix + '_excluded.txt') report_str = 'rsfMRI_preprocessing' wf = Workflow('qc_reports_wf') wf.base_dir = report_base_dir wf.config['execution']['crashdump_dir'] = os.path.join(report_base_dir, 'crash') wf.config['execution']['stop_on_first_crash'] = False # collect dfs df = pd.DataFrame() for TR in TR_list:
root_dir = '/data/liem-1/LIFE/' check_file_list = [ 'preprocessed/{subject_id}/resting_state/ants/rest_mni_unsmoothed_fullspectrum.nii.gz', 'preprocessed/{subject_id}/resting_state/ants/rest_mni_unsmoothed.nii.gz', 'preprocessed/{subject_id}/resting_state/denoise/rest_preprocessed_nativespace_fullspectrum.nii.gz', 'preprocessed/{subject_id}/resting_state/denoise/rest_preprocessed_nativespace.nii.gz', 'preprocessed/{subject_id}/resting_state/FWHM6/rest_mni_smoothed.nii.gz', 'preprocessed/{subject_id}/resting_state/realign/rest_realigned.par', 'preprocessed/{subject_id}/structural/transforms2mni/transform0GenericAffine.mat', 'preprocessed/{subject_id}/structural/transforms2mni/transform1InverseWarp.nii.gz', 'preprocessed/{subject_id}/structural/transforms2mni/transform1Warp.nii.gz', ] subjects_list = load_subjects_list( '/scr/adenauer2/Franz/LIFE16/LIFE16_preprocessed_subjects_list_n2557.txt') print subjects_list print('\n\n CHECKING FOR MISSING FILES...') missing_files = False for subject_id in subjects_list: for file_template in check_file_list: subject_file = os.path.join( root_dir, file_template.format(subject_id=subject_id)) # print subject_file if not os.path.exists(subject_file): print('MISSING FILE %s: %s' % (subject_id, subject_file)) missing_files = True if missing_files: print('\n SOME FILES MISSING')
import os, glob root_dir = '/data/liem-1/LIFE/' check_file_list = ['preprocessed/{subject_id}/resting_state/ants/rest_mni_unsmoothed_fullspectrum.nii.gz', 'preprocessed/{subject_id}/resting_state/ants/rest_mni_unsmoothed.nii.gz', 'preprocessed/{subject_id}/resting_state/denoise/rest_preprocessed_nativespace_fullspectrum.nii.gz', 'preprocessed/{subject_id}/resting_state/denoise/rest_preprocessed_nativespace.nii.gz', 'preprocessed/{subject_id}/resting_state/FWHM6/rest_mni_smoothed.nii.gz', 'preprocessed/{subject_id}/resting_state/realign/rest_realigned.par', 'preprocessed/{subject_id}/structural/transforms2mni/transform0GenericAffine.mat', 'preprocessed/{subject_id}/structural/transforms2mni/transform1InverseWarp.nii.gz', 'preprocessed/{subject_id}/structural/transforms2mni/transform1Warp.nii.gz', ] subjects_list = load_subjects_list('/scr/adenauer2/Franz/LIFE16/LIFE16_preprocessed_subjects_list_n2557.txt') print subjects_list print('\n\n CHECKING FOR MISSING FILES...') missing_files = False for subject_id in subjects_list: for file_template in check_file_list: subject_file = os.path.join(root_dir, file_template.format(subject_id=subject_id)) # print subject_file if not os.path.exists(subject_file): print('MISSING FILE %s: %s' % (subject_id, subject_file)) missing_files = True if missing_files: print('\n SOME FILES MISSING') else:
import pandas as pd from nipype.pipeline.engine import Node, Workflow import nipype.interfaces.utility as util from utils import get_condor_exit_status, check_if_wf_crashed, load_subjects_list from qc_reports.create_qc_report_pdf import create_qc_report_pdf from variables import ds_dir, report_base_dir, subjects_dir from variables import TR_list, full_subjects_list, subjects_file_prefix from variables import plugin_name, use_n_procs #fixme plugin_name = 'MultiProc' use_n_procs = 25 subjects_list = full_subjects_list subjects_missing_files_list = load_subjects_list( subjects_dir, subjects_file_prefix + '_excluded.txt') report_str = 'rsfMRI_preprocessing' wf = Workflow('qc_reports_wf') wf.base_dir = report_base_dir wf.config['execution']['crashdump_dir'] = os.path.join(report_base_dir, 'crash') wf.config['execution']['stop_on_first_crash'] = False # collect dfs df = pd.DataFrame() for TR in TR_list: rel_report_dir = os.path.join(report_str + '_TR_%s' % TR) os.chdir(report_base_dir)