Skip to content

Commit

Permalink
Fix group directive usage
Browse files Browse the repository at this point in the history
Fixed participant levels to only have 'participant' and 'group'. Also
fixed the group directive within snakemake, which is separate from the
analysis levels.
  • Loading branch information
kaitj committed Nov 2, 2022
1 parent 8012344 commit c258563
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
3 changes: 1 addition & 2 deletions dbsc/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ derivatives: False # Search in bids/derivatives if True; can also be path(s) to

# List of analysis levels in bids app
analysis_levels: &analysis_levels
- participant1
- participant
- group
- participant2

# Mapping from analysis_level to set of target rules or files
targets_by_analysis_level:
Expand Down
29 changes: 15 additions & 14 deletions dbsc/workflow/rules/mrtpipelines.smk
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ rule nii_to_mif:
space='T1w',
**config['subj_wildcards']
)
group: "subject_1"
container:
config['singularity']['mrtpipelines']
shell:
'mrconvert -nthreads {threads} -fslgrad {input.bvecs} {input.bvals} {input.dwi} {output.dwi} '
'mrconvert -nthreads {threads} {input.mask} {output.mask}'
group: participant1


rule estimate_response:
Expand Down Expand Up @@ -88,11 +88,11 @@ rule estimate_response:
suffix='response.txt',
**config['subj_wildcards'],
)
group: "subject_1"
container:
config['singularity']['mrtpipelines']
shell:
'dwi2response dhollander {input.dwi} {output.sfwm} {output.gm} {output.csf} -nthreads {threads}'
group: participant1

# TODO: Add check for pre-computed group response function
rule avg_response:
Expand Down Expand Up @@ -120,11 +120,11 @@ rule avg_response:
desc='csf',
suffix='response.txt',
)
group: "group"
container:
config['singularity']['mrtpipelines']
shell:
'average_response {input.sfwm} {output.avg_sfwm} {input.gm} {output.avg_gm} {input.csf} {output.csf}'
group: group


rule compute_fod:
Expand Down Expand Up @@ -160,6 +160,7 @@ rule compute_fod:
desc='csf',
suffix='fod.mif'
),
group: "subject_2"
container:
config['singularity']['mrtpipelines']
shell:
Expand All @@ -168,7 +169,6 @@ rule compute_fod:
'else '
' dwi2fod -nthreads {params.threads} -shell {params.shell} -lmax {params.lmax} -mask {input.mask} msmt_csd {input.dwi} {input.avg_sfwm} {output.wm_fod} {input.avg_gm} {output.gm_fod} {input.avg_csf} {output.csf} '
'fi'
group: participant2


rule normalise_fod:
Expand Down Expand Up @@ -204,11 +204,11 @@ rule normalise_fod:
suffix='fodnorm.mif',
**config['subj_wildcards'],
),
group: "subject_2"
container:
config['singularity']['mrtpipelines']
shell:
'mtnormalise -nthreads {params.threads} -mask {input.mask} {input.wm_fod} {output.wm_fod} {input.gm_fod} {output.gm_fod} {input.csf_fod} {output.csf_fod}'
group: participant2

# DTI (Tensor) Processing
rule dwi_normalise:
Expand Down Expand Up @@ -279,12 +279,12 @@ rule compute_tensor:
suffix='fa.mif',
**config['subj_wildcards'],
)
group: "subject_1"
container:
config['singularity']['mrtpipelines']
shell:
'dwi2tensor -nthreads {params.threads} -mask {input.mask} {input.dwi} {output.dti}'
'tensor2metric -nthreads {params.threads} -mask {input.mask} {output.dti} -fa {output.fa} -ad {output.ad} -rd {output.rd} -adc {output.md}'
group: participant1


# Tractography processing
Expand All @@ -308,11 +308,11 @@ rule gen_tractography:
suffix='tractography.tck',
**config["subj_wildcards"],
)
group: "subject_2"
container:
config['singularity']['mrtpipelines']
shell:
'tckgen -nthreads {params.threads} -algorithm iFOD2 -step {params.step} -select {params.sl_count} -exclude {input.cortical_ribbon} -exclude {input.convex_hull} -include {input.subcortical_seg} -mask {input.mask} -seed_image {input.mask} {input.fod} {output.tck}'
group: participant2

rule weight_tractography:
input:
Expand All @@ -338,11 +338,11 @@ rule weight_tractography:
**config['subj_wildcards'],
]
),
group: "subject_2"
container:
config['singularity']['mrtpipelines']
shell:
'tcksift2 -nthreads {params.threads} -out_mu {output.mu} {input.tck} {input.fod} {output.weights}'
group: participant2

# TODO: ADD OPTION TO OUTPUT TDI MAP

Expand Down Expand Up @@ -373,11 +373,11 @@ rule connectome_map:
suffix='nodeweights.csv'
**config['subj_wildcards'],
)
group: "subject_2"
container:
config['singularity']['mrtpipelines']
shell:
'tck2connectome -nthreads {params.threads} -zero_diagonal -stat_edge sum -assignment_radial_search {params.radius} -tck_weights_in {input.weights} -out_assignments {output.sl_assignment} -symmetric {input.tck} {input.subcortical_seg} {output.node_weights} '
group: participant2

rule extract_tck:
input:
Expand Down Expand Up @@ -407,14 +407,14 @@ rule connectome_map:
**config['subj_wildcards'],
)
),
group: "subject_2"
container:
config['singularity']['mrtpipelines'],
shell:
'for i in `seq 2 72`; do '
' nodes=$nodes,$i '
'done '
'connectome2tck -nthreads {params.threads} -nodes $nodes -exclusive -filters_per_edge -tck_weights_in {input.node_weights} -prefix_tck_weights_out {output.edge_weight} {input.tck} {input.sl_assignment} {output.edge_tck} '
group: participant2

# NOTE: Pass labelmerge split segs here?
rule create_roi_mask:
Expand All @@ -433,6 +433,7 @@ rule connectome_map:
suffix='mask.mif'
)
),
group: "subject_2"
container:
config['singularity']['mrtpipelines'],
shell:
Expand Down Expand Up @@ -503,12 +504,12 @@ rule connectome_map:
suffix='weights.csv'
)
)
group: "subject_2"
containers:
config['singularity']['mrtpipelines'],
shell:
'mrcalc -nthreads {params.threads} {input.subcortical_seg} 0 -neq {input.roi1} -sub {input.roi2} -sub {input.lZI} -sub {input.rZI} -sub {output.filter_mask} '
'tckedit -nthreads {params.therads} -exclude {output.filter_mask} -tck_weights_in {input.weights} -tck_weights_out {output.filtered_weights} {input.tck} {output.filtered_tck} '
group: participant2

rule combine_filtered:
input:
Expand All @@ -531,12 +532,12 @@ rule connectome_map:
desc='subcortical',
suffix='tckweights.txt'
)
group: "subject_2"
container:
config['singularity']['mrtpipelines'],
shell:
'tckedit {input.tck} {output.combined_tck} '
'cat {input.weights} >> {output.combined_weights} '
group: participant2

rule filtered_connectome_map:
input:
Expand All @@ -563,8 +564,8 @@ rule connectome_map:
suffix='nodeweights.csv'
**config['subj_wildcards'],
)
group: "subject_2"
container:
config['singularity']['mrtpipelines']
shell:
'tck2connectome -nthreads {params.threads} -zero_diagonal -stat_edge sum -assignment_radial_search {params.radius} -tck_weights_in {input.weights} -out_assignments {output.sl_assignment} -symmetric {input.tck} {input.subcortical_seg} {output.node_weights} -force'
group: participant2
'tck2connectome -nthreads {params.threads} -zero_diagonal -stat_edge sum -assignment_radial_search {params.radius} -tck_weights_in {input.weights} -out_assignments {output.sl_assignment} -symmetric {input.tck} {input.subcortical_seg} {output.node_weights} -force'

0 comments on commit c258563

Please sign in to comment.