<jupyter_start><jupyter_text>NeuroMet Instructions:* this notebook cannot be used for two different analysis at the same time. If you are unsure if someone is using it click on File / Make a copy and work with the copy.* to run a cell press Umschalt (Shift) + Enter* to correctly run the workflow _EVERY_ cell has to be ran* When you run a cell, there is at first an [*] on the left, then a number (maybe an updated number) when the cell ran.* normally the only thing to adjust in the settings is 1.6 Subject<jupyter_code>## External Modules
import os, glob 
from pipeline.NeuroMet2_dev_fs7 import NeuroMet
from IPython.display import Image
%matplotlib inline
## Settings
## Paths
raw_data_dir = '/media/drive_s/AG/AG-Floeel-Imaging/00-Rohdaten/02_niftis/NeuroMET2_LauraGöschel/2_Messkohorte'
base_dir = '/media/drive_s/AG/AG-Floeel-Imaging/02-User/NEUROMET2'
temp_dir = '/home/WorkFlowTemp/NeuroMet2_fs7_quant'

#Working directory
w_dir = os.path.join(base_dir, 'Structural_Analysis_fs7_quant')


#cores
cores = 6
omp_nthreads = 3

#overwrite copied files?
overwrite = False<jupyter_output><empty_output><jupyter_text>**subject_list**:* to analyze all subjects cut&paste below: `subject_list = [ x.split('/')[-1][8:11] for x in os.listdir(w_dir) if x.startswith('NeuroMet')]`* to analyse only some subjects use the format: `subject_list = ['subject number', 'subject number' ... ]` i.e.: `subject_list = ['001']` or `subject_list = ['001', '003']`<jupyter_code>subject_list = ['2054T1', '2059T1', '2060T1', '2061T1', '2106T1', '2107T1', '2108T1', '2004T2', '2006T2']
# Workflow - 1st part - SPM Segment and Mask generation
neuromet_creator = NeuroMet(subject_list, temp_dir, w_dir, omp_nthreads, raw_data_dir, overwrite)
## Copy from raw data
neuromet_creator.copy_from_raw_data()
## Tissue Segmentation Pipeline
neuromet = neuromet_creator.make_neuromet1_workflow()
neuromet.write_graph(graph2use = 'colored', dotfilename = './imgs/neuromet')
Image(filename='./imgs/neuromet.png')
%%time
neuromet.run('MultiProc', plugin_args={'n_procs': cores})
# Create combined image and Freesurfer analysis
print(subject_list)
# Uncomment here for all subjects:
#subject_list = [ x.split('/')[-1][8:11] for x in uni ]

# only some subjects? Then edit here:  
#subject_list = ['2004']
import importlib
from pipeline import NeuroMet2_dev_fs7
importlib.reload(NeuroMet2_dev_fs7)
from pipeline.nodes import qdec
importlib.reload(qdec)
neuromet_creator = NeuroMet2_dev_fs7.NeuroMet(subject_list,
                                              temp_dir,
                                              w_dir,
                                              omp_nthreads,
                                              raw_data_dir,
                                              overwrite)
neuromet_fs = neuromet_creator.make_neuromet_fs_workflow()
neuromet_fs.write_graph(graph2use = 'colored', dotfilename = './imgs/neuromet_fs')
Image(filename='./imgs/neuromet_fs.png')
## Run Freesurfer Analysis
%%time
neuromet2.run('MultiProc', plugin_args={'n_procs': cores})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1103874959296646, 'fraction_numerical': 0.030934549006838164, 'mean_word_length': 3.995121951219512, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '653463', 'license': 'MIT', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1028, 'n_words': 265, 'path': 'NeuroMET2_FreeSurfer7.ipynb', 'repo_name': 'HippieAtrophy/NeuroMet2_structural_analysis', 'size': '3071'}