Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labelmerge #30

Merged
merged 16 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
test/data/derivatives/.snakemake/
test/data/derivatives/config/
test/data/derivatives/.snakebids

# Tar files
*.tar

# Ignore files that are available in tar
**/zona_bb_subcortex/MNI152
**/zona_bb_subcortex/MNI2009b
**/zona_bb_subcortex/transforms
23 changes: 11 additions & 12 deletions dbsc/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,28 @@ parse_args:

# Workflow specific config
# Spaces available (MNI152, MNINlin2009bAsym)
Space: MNI152
Space: MNI152NLin6Asym

zona_bb_subcortex:
MNI152:
dir: 'resources/MNI152'
T1w: 'resources/MNI152/sub-SNSX32NLin2020Asym_space-MNI152_T1w.nii.gz'
seg: 'resources/MNI152/sub-SNSX32NLin2020Asym_space-MNI152_ZonaBBSubCorSeg.nii.gz'
exclude: 'resources/MNI152/sub-SNSX32NLin2020Asym_space-MNI152_desc-exclude_ROI.nii.gz'
MNI2009:
dir: 'resources/MNI2009b'
T1w: 'resources/MNI2009b/sub-SNSX32NLin2020Asym_space-MNI152_T1w.nii.gz'
seg: 'resources/MNI2009b/sub-SNSX32NLin2020Asym_space-MNINlin2009bAsym_ZonaBBSubCorSeg.nii.gz'
exclude: 'resources/MNI2009b/sub-SNSX32NLin2020Asym_space-MNINlin2009bAsym_desc-exclude_ROI.nii.gz'
tsv: 'resources/zona_bb_subcortex/desc-ZonaBBSubcor_dseg.tsv'
MNI152NLin6Asym:
dir: 'resources/zona_bb_subcortex/MNI152NLin6Asym/'
T1w: 'tpl-MNI152NLin6Asym_res-04_desc-brain_T1w.nii.gz'
seg: 'sub-SNSX32NLin2020Asym_space-MNI152NLin6Asym_desc-ZonaBBSubcor_dseg.nii.gz'
MNI152NLin2009bAsym:
dir: 'resources/zona_bb_subcortex/MNI152NLin2009bAsym/'
seg: 'sub-SNSX32NLin2020Asym_space-MNI152NLin2009bAsym_desc-ZonaBBSubcor_dseg.nii.gz'

# NOTE: This may not be needed with labelmerge
freesurfer:
labels: 'resources/freesurfer/fs_labels.csv'
tsv: 'resources/freesurfer/desc-FreesurferThal_dseg.tsv'

# Containers
# NOTE: Update from latest to use specific tags
singularity:
freesurfer: "docker://pwighton/freesurfer:7.2.0"
neuroglia-core: "docker://khanlab/neuroglia-core:latest"
mrtrix: "docker://brainlife/mrtrix:3.0.3"
labelmerge: "docker://kaitj/labelmerge:v0.1.0"

fs_license: /path/to/fs/license
53 changes: 53 additions & 0 deletions dbsc/resources/freesurfer/desc-FreesurferThal_dseg.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
index name
8108 Left LD
8208 Right LD
8109 Left LGN
8209 Right LGN
8115 Left MGN
8215 Right MGN
8121 Left PuI
8221 Right PuI
8123 Left PuM
8223 Right PuM
8111 Left L-Sg
8211 Right L-Sg
8133 Left VPL
8233 Right VPL
8106 Left CM
8206 Right CM
8128 Left VLa
8228 Right VLa
8120 Left PuA
8220 Right PuA
8113 Left MDm
8213 Right MDm
8118 Left Pf
8218 Right Pf
8127 Left VAmc
8227 Right VAmc
8112 Left MDl
8212 Right MDl
8104 Left CeM
8204 Right CeM
8126 Left VA
8226 Right VA
8116 Left MV(Re)
8216 Right MV(Re)
8125 Left R
8225 Right R
8130 Left VM
8230 Right VM
8105 Left CL
8205 Right CL
8122 Left PuL
8222 Right PuL
8119 Left Pt
8219 Right Pt
8103 Left AV
8203 Right AV
8117 Left Pc
8217 Right Pc
8129 Left VLp
8229 Right VLp
8110 Left LP
8210 Right LP
51 changes: 0 additions & 51 deletions dbsc/resources/freesurfer/fs_labels.csv

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
25 changes: 25 additions & 0 deletions dbsc/resources/zona_bb_subcortex/desc-ZonaBBSubcor_dseg.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
index name
1 Left RN
2 Right RN
3 Left SN
4 Right SN
5 Left STn
6 Right STn
7 Left Caudate
8 Right Caudate
9 Left Putamen
10 Right Putamen
11 Left GPe
12 Right GPe
13 Left GPi
14 Right GPi
15 Left Thalamus
16 Right Thalalmus
17 Left Hippocampus
18 Right Hippocampus
19 Left NAc
20 Right NAc
21 Left Amygdala
22 Right Amygdala
23 Left ZI
24 Right ZI
73 changes: 0 additions & 73 deletions dbsc/resources/zona_bb_subcortex/subcortical-labels.csv

This file was deleted.

4 changes: 3 additions & 1 deletion dbsc/workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ include: "rules/mrtpipelines.smk"

rule all:
input:
expand(
files=expand(
rules.filtered_tck2connectome.output.sl_assignment,
subject=config["input_lists"]["T1w"]["subject"],
),
fs_tsv=rules.cp_fs_tsv.output.fs_tsv,
zona_tsv=rules.cp_zona_tsv.output.zona_tsv,
16 changes: 16 additions & 0 deletions dbsc/workflow/rules/freesurfer.smk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ bids_fs_out = partial(
# B. Fischl, A. van der Kouwe, C. Destrieux, E. Halgren, F. Ségonne, D.H. Salat, E. Busa, L.J. Seidman, J. Goldstein, D. Kennedy, V. Caviness, N. Makris, B. Rosen, A.M. Dale. Automatically parcellating the human cerebral cortex. Cereb. Cortex, 14 (2004), pp. 11-22, 10.1093/cercor/bhg087


rule cp_fs_tsv:
"""Copy tsv to freesurfer dir
"""
input:
fs_tsv=str(
Path(workflow.basedir).parent / Path(config["freesurfer"]["tsv"])
),
output:
fs_tsv=expand(
"{freesurfer_dir}/desc-FreesurferThal_dseg.tsv",
freesurfer_dir=freesurfer_dir,
),
shell:
"cp -v {input.fs_tsv} {output.fs_tsv}"


rule thalamic_segmentation:
"""Perform thalamus segmentation

Expand Down
15 changes: 7 additions & 8 deletions dbsc/workflow/rules/mrtpipelines.smk
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ rule dwi2response:

rule responsemean:
"""Compute average response function"""
# DOUBLE CHECK
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we double checking here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, this was a note to my self, I removed it in one of the other PRs. Just wanted to check the conditional was written correctly by comparing with an existing rule written in another workflow.

input:
subject_rf=expand(
bids_response_out(
Expand Down Expand Up @@ -317,7 +318,7 @@ rule tckgen:
mask=rules.nii2mif.output.mask,
cortical_ribbon=rules.fs_xfm_to_native.output.ribbon,
convex_hull=rules.create_convex_hull.output.convex_hull,
subcortical_seg=rules.add_brainstem_new_seg.output.seg,
subcortical_seg=rules.add_brainstem.output.mask,
params:
step=config["step"],
sl=config["sl_count"],
Expand Down Expand Up @@ -367,7 +368,7 @@ rule tck2connectome:
input:
weights=rules.tcksift2.output.weights,
tck=rules.tckgen.output.tck,
subcortical_seg=rules.add_brainstem_new_seg.output.seg,
subcortical_seg=rules.add_brainstem.output.mask,
params:
radius=config["radial_search"],
output:
Expand Down Expand Up @@ -417,11 +418,9 @@ rule connectome2tck:
"connectome2tck -nthreads {threads} -nodes {params.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} "


# NOTE: Use labelmerge split segs here?
rule create_roi_mask:
# EXPAND OVER NODE1 IN RULE ALL
input:
subcortical_seg=rules.add_brainstem_new_seg.output.seg,
subcortical_seg=rules.add_brainstem.output.mask,
output:
roi_mask=temp(
bids_anat_out(
Expand Down Expand Up @@ -450,7 +449,7 @@ rule create_exclude_mask:
),
lZI=bids_anat_out(desc="21", suffix="mask.mif"),
rZI=bids_anat_out(desc="22", suffix="mask.mif"),
subcortical_seg=rules.add_brainstem_new_seg.output.seg,
subcortical_seg=rules.add_brainstem.output.mask,
output:
filter_mask=temp(
bids_anat_out(
Expand All @@ -472,7 +471,7 @@ rule filter_tck:
filter_mask=rules.create_exclude_mask.output.filter_mask,
tck=rules.connectome2tck.output.edge_tck,
weights=rules.tck2connectome.output.node_weights,
subcortical_seg=rules.add_brainstem_new_seg.output.seg,
subcortical_seg=rules.add_brainstem.output.mask,
output:
filtered_tck=temp(
bids_tractography_out(
Expand Down Expand Up @@ -537,7 +536,7 @@ rule filtered_tck2connectome:
input:
weights=rules.combine_filtered.output.combined_weights,
tck=rules.combine_filtered.output.combined_tck,
subcortical_seg=rules.add_brainstem_new_seg.output.seg,
subcortical_seg=rules.add_brainstem.output.mask,
params:
radius=config["radial_search"],
output:
Expand Down
Loading