Skip to content

Commit

Permalink
Dev rr1 (#2)
Browse files Browse the repository at this point in the history
* updated CLI for step1

* updated step2 CLI

* starting traditional approach

* point-wise glm done

* added plotting

* updated documentation

* working on figures

* added shading to plot_diff

* added tukey stats to memory plot

* restructuring

* renaming files

* reorganizing

* updated notes

* Update README.md

* Update README.md

* added GAM for MD

* added print out for memory stats, session

* updated notes, decreased shade opacity

* decreased opacity
  • Loading branch information
nmuncy authored Jan 10, 2022
1 parent ae3a53a commit 18057da
Show file tree
Hide file tree
Showing 19 changed files with 128,930 additions and 309 deletions.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
# emu_AFQ

Scripts are named in their respective order.
Repo containing code, documents, and data used in the manuscript "General Additive Models Address Statistical Issues in Diffusion MRI: An Example with Clinically Anxious Adolescents".

afq_step1 - deals with pulling data and getting organized for pyAFQ.
# Code

afq_step2 - run pyAFQ CLI on data.
Various scripts for organizing DWI data, running pyAFQ, and conducting statistical analyses. Scripts are named (a) for their respective order in the workflow, and (b) with a description of their function.

afq_step3 - model tract FA values with a GAM, conduct tests.
- step1_submit.sh : Set up, copy data, and wrap step1_setup.py
- step1_setup.py : Configure config.toml for pyAFQ CLI
- step2_submit.sh : Wrap step2_CLI.sh
- step2_CLI.sh : Run AFQ via pyAFQ on Slurm scheduled resources
- step3_manuscript_stats.R : Code used to conduct statistical analyses reported in the manuscript. Unused analyses, portions remain for potential future analyses and transparency.
- step3_reduced_stats.R : Illustrative code to aid in the implementation of using a GAM method with AFQ output
- step4_quick_stats.R : Quick queries for the manuscript
- step5_reviewer_stats.R : Code written to address reviewer concerns, in addition to updates to step3_manuscript_stats.R and step4_quick_stats.R.

afq_step4 - make quick figures, stats for manuscript.

Other files: config.toml is the file referenced by afq_step2, and tract_profiles.csv is the output of afq_step2.
# Data

Contains data used in the manuscript.

- tract_profiles.csv : pyAFQ output
- Master_dataframe_G3.csv : pyAFQ output with demographic information added for groupings according to PARS-6 tertiles


# Docs

Documents used to conduct analyses or to aid in replication.

- config.toml : Configuration file used with pyAFQ
- R_session_info.txt : A complete description of all packages and versions used in the analyses
51 changes: 0 additions & 51 deletions R_session_info.txt

This file was deleted.

13 changes: 0 additions & 13 deletions afq_step2_CLI.sh

This file was deleted.

85 changes: 85 additions & 0 deletions code/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[BIDS]
bids_path = "/scratch/madlab/emu_AFQ"
bids_filters = "{'suffix': 'dwi'}"
dmriprep = "all"
custom_tractography_bids_filters = ""

[REGISTRATION]
b0_threshold = 50
patch2self = false
robust_tensor_fitting = false
min_bval = ""
max_bval = ""
reg_template = "mni_T1"
reg_subject = "power_map"
brain_mask = "B0Mask({})"
mapping = "SynMap(True, {}, {})"

[PROFILE]
profile_weights = "gauss"

[BUNDLES]
bundle_info = ""
scalars = [ "dti_fa", "dti_md",]

[COMPUTE]
dask_it = false

[VIZ]
virtual_frame_buffer = false
viz_backend = "plotly_no_gif"

[TRACTOGRAPHY]
directions = "prob"
max_angle = 30.0
sphere = ""
seed_mask = ""
seed_threshold = 0
n_seeds = 1
random_seeds = false
rng_seed = ""
stop_mask = ""
stop_threshold = 0
step_size = 0.5
min_length = 10
max_length = 1000
odf_model = "DTI"
tracker = "local"

[SEGMENTATION]
nb_points = false
nb_streamlines = false
seg_algo = "AFQ"
reg_algo = ""
clip_edges = false
parallel_segmentation = "{'n_jobs': -1, 'engine': 'joblib', 'backend': 'loky'}"
progressive = true
greater_than = 50
rm_small_clusters = 50
model_clust_thr = 1.25
reduction_thr = 25
refine = false
pruning_thr = 12
b0_threshold = 50
prob_threshold = 0
dist_to_waypoint = ""
rng = ""
return_idx = false
presegment_bundle_dict = ""
presegment_kawrgs = "{}"
filter_by_endpoints = true
endpoint_info = ""
dist_to_atlas = 4
save_intermediates = ""

[CLEANING]
n_points = 100
clean_rounds = 5
distance_threshold = 5
length_threshold = 4
min_sl = 20
stat = "mean"
return_idx = false

[files]
dmriprep_folder = "/scratch/madlab/emu_AFQ/derivatives/dwi_preproc"
55 changes: 37 additions & 18 deletions afq_step1_setup.py → code/step1_setup.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,74 @@
"""Setup config.toml file for AFQ
"""Setup config.toml file for AFQ.
This script will edit the BIDs file dataset_description.json
with values needed by AFQ. It will then edit the AFQ
configuration file config.toml with project-specific values.
It is wrapped by afq_step1_submit.sh.
It is wrapped by step1_submit.sh.
Examples
--------
python step1_setup.py \\
-c config.toml \\
-b /scratch/madlab/emu_AFQ \\
-d /scratch/madlab/emu_AFQ/derivatives/dwi_preproc \\
-j /scratch/madlab/emu_AFQ/dataset_description.json \\
-p dwi_preproc
"""

import os
import sys
import toml
import json
from argparse import ArgumentParser
import textwrap
from argparse import ArgumentParser, RawTextHelpFormatter


def get_args():
parser = ArgumentParser("Receive bash args from afq_step1_submit.sh wrapper")
"""Get and parse arguments."""
parser = ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
parser.add_argument(
"-c",
"--config-file",
help="/path/to/afq/config.toml",
"-p",
"--preproc-dwi",
type=str,
required=True,
default="dwi_preproc",
help=textwrap.dedent(
"""\
Description str for pre-processed DWI
(default : %(default)s)
"""
),
)
parser.add_argument(
required_args = parser.add_argument_group("Required Arguments")
required_args.add_argument(
"-c", "--config-file", help="/path/to/afq/config.toml", type=str, required=True,
)
required_args.add_argument(
"-b",
"--bids-directory",
help="/path/to/bids/project_directory",
type=str,
required=True,
)
parser.add_argument(
required_args.add_argument(
"-d",
"--deriv-directory",
help="/path/to/bids/project_directory/derivatives/pre-processed_dwi",
type=str,
required=True,
)
parser.add_argument(
required_args.add_argument(
"-j",
"--json-file",
help="/path/to/bids/project_directory/dataset_description.json",
type=str,
required=True,
)
parser.add_argument(
"-p",
"--preproc-dwi",
help="Description str for pre-processed DWI",
type=str,
default="dwi_preproc",
)

if len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)

return parser


Expand Down
Loading

0 comments on commit 18057da

Please sign in to comment.