import pandas as pd
from os.path import join

configfile: 'config/config.yml'

#load participants.tsv file, and strip off sub- from participant_id column
df = pd.read_table(config['participants_tsv'])
subjects = df.participant_id.to_list() 
subjects = [ s.strip('sub-') for s in subjects ]

hemis = 'lh rh'.split()

#needed since std meshes sometimes use L/R instead of lh/rh
hemi_to_H = dict({'lh': 'L', 'rh': 'R'})

#get list of ROIs
f = open(config['targets_txt'],'r')
targets = [line.strip() for line in f.readlines()]
f.close()

#get seeds, as keys in template_prob_seg
seeds = config['template_prob_seg'].keys()


#bids-naming for subject and template (only alphanumeric characters)
wildcard_constraints:
    subject="[a-zA-Z0-9]+",
    template="[a-zA-Z0-9]+",
    seed="[a-zA-Z0-9]+",
    surfname='white|pial|sphere.reg',
    volname='T1'

include: 'rules/hcp7T_Diffusion_bedpostx_gpu.smk'

include: 'rules/hcp_mmp.smk'


rule all:
    input: expand('results/clustering/group_space-{template}_seed-{seed}_method-spectralcosine_k-{k}_cluslabels.nii.gz',template=config['template'],seed=seeds,k=range(2,config['max_k']+1))


include: 'rules/diffparc.smk'
