diff --git a/spimquant/config/snakebids.yml b/spimquant/config/snakebids.yml index 551c40d..c2bb076 100644 --- a/spimquant/config/snakebids.yml +++ b/spimquant/config/snakebids.yml @@ -63,35 +63,12 @@ parse_args: - MBMv3 - turone - --template_mri: - help: "Template to use for MRI registration to obtain brain mask\n" - default: MouseIn - choices: - - MouseIn - - DSURQE - - MBMv3 - - turone - --atlas_segs: - help: "Atlas segmentations to use with the chosen template (default: use them all)" + help: "Atlas segmentations to use with the chosen template (default: predefined list or all)" default: null action: store nargs: '+' - --patch_atlas_segs: - help: "Atlas segmentations to use for extracting patches (default: roi22)" - default: - - roi22 - action: store - nargs: '+' - - - - --template_negative_mask: - help: "Negative mask, in the template space, to highlight regions to avoid\n" - type: Path - default: placeholder - --template_crop: help: "Crop template along X-axis to retain specific hemisphere for registration (default: %(default)s)" choices: @@ -105,13 +82,14 @@ parse_args: - PI - YOPRO - YoPro + - YoPro1 - AutoF - autof action: store nargs: '+' --stains_for_seg: - help: "List of stains to use for segmentation and quantification\n (default: %(default)s)" + help: "List of stains to use for segmentation and quantification (will segment any that match the data)\n (default: %(default)s)" default: - abeta - Abeta @@ -123,7 +101,7 @@ parse_args: nargs: '+' --stains_for_vessels: - help: "List of stains to use for vessel segmentation and quantification\n (default: %(default)s)" + help: "List of stains to use for vessel segmentation and quantification (will choose first available, in order)\n (default: %(default)s)" default: - CD31 - Lectin @@ -131,11 +109,13 @@ parse_args: nargs: '+' --registration_level: - help: "Downsampling level to use for registration (level 0 is full res, level 1 is 50% size, ...) (default: %(default)s)" + help: "Downsampling level to use for registration (level 0 is full res, level 1 is 50% size, ...) (default: 5)" + type: int default: 5 --segmentation_level: - help: "Downsampling level to use for segmentation (level 0 is full res, level 1 is 50% size, ...) (default: %(default)s)" + help: "Downsampling level to use for segmentation (including vessels) (level 0 is full res, level 1 is 50% size, ...) (default: 0)" + type: int default: 0 --no_segmentation: @@ -179,6 +159,15 @@ parse_args: action: store_true default: False + --template_mri: + help: "Template to use for MRI registration to obtain brain mask\n" + default: MouseIn + choices: + - MouseIn + - DSURQE + - MBMv3 + - turone + --mri_resample_percent: help: "Resampling factor for multi-MRI averaging to create super-resolved images, as a percent (default: %(default)s). Use 200 for upsampling to twice the resolution" default: 100 @@ -219,6 +208,14 @@ parse_args: nargs: 3 type: int + --patch_atlas_segs: + help: "Atlas segmentations to use for extracting patches (default: coarse)" + default: + - coarse + action: store + nargs: '+' + + --n_patches_per_label: help: "Number of patches to extract per atlas label (default: %(default)s)" default: 5 @@ -240,11 +237,12 @@ parse_args: nargs: '+' --crop_atlas_segs: - help: "Atlas segmentations to use for extracting Imaris crops (default: roi22)" + help: "Atlas segmentations to use for extracting Imaris crops (default: coarse)" default: - - roi22 + - coarse action: store nargs: '+' + --contrast_column: help: "Column name in participants.tsv to use for defining group contrasts (e.g., 'treatment', 'genotype'). Required for group-level statistical analysis." default: null diff --git a/spimquant/workflow/Snakefile b/spimquant/workflow/Snakefile index 3e8b5fb..2a6fa96 100644 --- a/spimquant/workflow/Snakefile +++ b/spimquant/workflow/Snakefile @@ -11,7 +11,7 @@ tpl_spec = spec[0].copy() tpl_spec["entity"] = "template" tpl_spec["tag"] = "tpl" spec.insert(0, tpl_spec) -snakebids.set_bids_spec(spec) +set_bids_spec(spec) configfile: "config/snakebids.yml" diff --git a/spimquant/workflow/rules/counts.smk b/spimquant/workflow/rules/counts.smk index 8e8f0b1..a65965b 100644 --- a/spimquant/workflow/rules/counts.smk +++ b/spimquant/workflow/rules/counts.smk @@ -90,7 +90,7 @@ rule coloc_per_voxel_template: ), threads: 16 resources: - mem_mb=15000, + mem_mb=64000, runtime=30, script: "../scripts/coloc_per_voxel_template.py" diff --git a/spimquant/workflow/rules/regionprops.smk b/spimquant/workflow/rules/regionprops.smk index f40036e..5fbd14c 100644 --- a/spimquant/workflow/rules/regionprops.smk +++ b/spimquant/workflow/rules/regionprops.smk @@ -134,10 +134,10 @@ rule colocalize_regionprops: suffix="coloc.parquet", **inputs["spim"].wildcards, ), - threads: 1 + threads: 16 resources: - mem_mb=1500, - runtime=30, + mem_mb=64000, + runtime=180, script: "../scripts/compute_colocalization.py" @@ -180,9 +180,9 @@ rule sample_at_vessel_sdt: suffix="regionprops.parquet", **inputs["spim"].wildcards, ), - threads: 1 + threads: 8 resources: mem_mb=32000, - runtime=30, + runtime=360, script: "../scripts/sample_at_points.py" diff --git a/spimquant/workflow/rules/segmentation.smk b/spimquant/workflow/rules/segmentation.smk index bc95e73..9b13252 100644 --- a/spimquant/workflow/rules/segmentation.smk +++ b/spimquant/workflow/rules/segmentation.smk @@ -236,38 +236,3 @@ rule clean_segmentation: runtime=30, script: "../scripts/clean_segmentation.py" - - -rule deform_negative_mask_to_subject_nii: - input: - ref=bids( - root=root, - datatype="micr", - stain=stain_for_reg, - level="{level}", - suffix="SPIM.nii.gz", - **inputs["spim"].wildcards, - ), - mask=config["template_negative_mask"], - xfm_composite_inv=rules.compose_subject_to_template_warp.output.xfm_composite_inv, - output: - mask=bids( - root=root, - datatype="seg", - desc="negative", - level="{level}", - from_="{template}", - suffix="mask.nii.gz", - **inputs["spim"].wildcards, - ), - threads: 32 - resources: - mem_mb=1500, - runtime=15, - conda: - "../envs/ants.yaml" - shell: - "ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS={threads} " - "antsApplyTransforms -d 3 -v -n NearestNeighbor " - " -i {input.mask} -o {output.mask} " - " -r {input.ref} -t {input.xfm_composite_inv}" diff --git a/spimquant/workflow/rules/segstats.smk b/spimquant/workflow/rules/segstats.smk index 816a307..38c5a0f 100644 --- a/spimquant/workflow/rules/segstats.smk +++ b/spimquant/workflow/rules/segstats.smk @@ -39,9 +39,9 @@ rule map_regionprops_to_atlas_rois: **inputs["spim"].wildcards, ) ), - threads: 1 + threads: 4 resources: - mem_mb=1500, + mem_mb=32000, runtime=15, script: "../scripts/map_atlas_to_regionprops.py" @@ -84,9 +84,9 @@ rule map_coloc_to_atlas_rois: **inputs["spim"].wildcards, ) ), - threads: 1 + threads: 4 resources: - mem_mb=1500, + mem_mb=32000, runtime=15, script: "../scripts/map_atlas_to_coloc.py"