Skip to content

Commit

Permalink
Revert "initial attempt at moving all resources files to OSF"
Browse files Browse the repository at this point in the history
This reverts commit 608eff6.
  • Loading branch information
Jordan DeKraker - B. Bernhardt Lab authored and kaitj committed Nov 16, 2023
1 parent c093610 commit ccf04a6
Show file tree
Hide file tree
Showing 103 changed files with 1,064 additions and 152 deletions.
8 changes: 8 additions & 0 deletions hippunfold/config/nnunet_model_urls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
T1w: 'https://zenodo.org/record/4508747/files/trained_model.3d_fullres.Task101_hcp1200_T1w.nnUNetTrainerV2.model_best.tar'
T2w: 'https://zenodo.org/record/4508747/files/trained_model.3d_fullres.Task102_hcp1200_T2w.nnUNetTrainerV2.model_best.tar'
neonateT1w: 'https://zenodo.org/record/5733556/files/trained_model.3d_fullres.Task205_hcp1200_b1000_finetuneround2_dhcp_T1w.nnUNetTrainerV2.model_best.tar'
neonateT1w_v2: 'https://zenodo.org/record/8209029/files/trained_model.3d_fullres.Task301_dhcp_T1w_synthseg_manuallycorrected.nnUNetTrainer.model_best.tar'
hippb500: 'https://zenodo.org/record/5732291/files/trained_model.3d_fullres.Task110_hcp1200_b1000crop.nnUNetTrainerV2.model_best.tar'
T1T2w: 'https://zenodo.org/record/4508747/files/trained_model.3d_fullres.Task103_hcp1200_T1T2w.nnUNetTrainerV2.model_best.tar'
synthseg_v0.1: 'https://dropbox.com/s/asoanq94ofersv3/trained_model.3d_fullres.Task102_synsegGenDetailed.nnUNetTrainerV2.model_best.tar'
synthseg_v0.2: 'https://www.dropbox.com/scl/fi/69yvmo38gdn3dj8aupq9z/trained_model.3d_fullres.Task203_synthseg.nnUNetTrainerV2.model_best.tar?rlkey=90km7u4t0cw8t15akr5tawxyl&dl=0'
94 changes: 40 additions & 54 deletions hippunfold/config/snakebids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,12 @@ template: CITI168

template_files:
CITI168:
T1w: templates-3d/CITI168/T1w_head_700um.nii.gz
T2w: templates-3d/CITI168/T2w_head_700um.nii.gz
xfm_corobl: templates-3d/CITI168/CoronalOblique_rigid.txt
crop_ref: templates-3d/CITI168/T2w_300umCoronalOblique_hemi-{hemi}.nii.gz
crop_refT1w: templates-3d/CITI168/T1w_300umCoronalOblique_hemi-{hemi}.nii.gz
Mask_crop: templates-3d/CITI168/Mask_300umCoronalOblique_hemi-{hemi}.nii.gz
T1w: resources/templates-3d/CITI168/T1w_head_700um.nii.gz
T2w: resources/templates-3d/CITI168/T2w_head_700um.nii.gz
xfm_corobl: resources/templates-3d/CITI168/CoronalOblique_rigid.txt
crop_ref: resources/templates-3d/CITI168/T2w_300umCoronalOblique_hemi-{hemi}.nii.gz
crop_refT1w: resources/templates-3d/CITI168/T1w_300umCoronalOblique_hemi-{hemi}.nii.gz
Mask_crop: resources/templates-3d/CITI168/Mask_300umCoronalOblique_hemi-{hemi}.nii.gz
dHCP:
T1w: resources/tpl-dHCP/cohort-1/tpl-dHCP_cohort-1_res-1_T1w.nii.gz
T2w: resources/tpl-dHCP/cohort-1/tpl-dHCP_cohort-1_res-1_T2w.nii.gz
Expand All @@ -377,30 +377,31 @@ template_files:
crop_refT1w: resources/CITI168/T1w_300umCoronalOblique_hemi-{hemi}.nii.gz
Mask_crop: resources/CITI168/Mask_300umCoronalOblique_hemi-{hemi}.nii.gz
upenn:
dseg: templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: templates-3d/tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz
dseg: resources/templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: resources/templates-3d/tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz
MBMv2:
T1w: templates-3d/tpl-MBMv2/Template_sym_MTR_80um.nii.gz
T2w: templates-3d/tpl-MBMv2/Template_sym_T2_80um.nii.gz
xfm_corobl: templates-3d/tpl-MBMv2/tpl-MBMv2_from-native_to-corobl_type-itk_affine.txt
crop_ref: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_MTR.nii.gz
Mask_crop: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-R_space-corobl_desc-tissuemanual_dseg.nii.gz
coords: templates-3d/tpl-MBMv2/tpl-MBMv2_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
T1w: resources/templates-3d/tpl-MBMv2/Template_sym_MTR_80um.nii.gz
T2w: resources/templates-3d/tpl-MBMv2/Template_sym_T2_80um.nii.gz
xfm_corobl: resources/templates-3d/tpl-MBMv2/tpl-MBMv2_from-native_to-corobl_type-itk_affine.txt
crop_ref: resources/templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: resources/templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_MTR.nii.gz
Mask_crop: resources/templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: resources/templates-3d/tpl-MBMv2/tpl-MBMv2_hemi-R_space-corobl_desc-tissuemanual_dseg.nii.gz
coords: resources/templates-3d/tpl-MBMv2/tpl-MBMv2_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
MBMv3:
T1w: templates-3d/tpl-MBMv3/tpl-MBMv3_T1w.nii.gz
T2w: templates-3d/tpl-MBMv3/tpl-MBMv3_T2w.nii.gz
xfm_corobl: templates-3d/tpl-MBMv3/tpl-MBMv3_from-native_to-corobl_type-itk_affine.txt
crop_ref: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T1w.nii.gz
Mask_crop: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-R_space-corobl_desc-tissue_dseg.nii.gz
coords: templates-3d/tpl-MBMv3/tpl-MBMv3_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
T1w: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_T1w.nii.gz
T2w: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_T2w.nii.gz
xfm_corobl: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_from-native_to-corobl_type-itk_affine.txt
crop_ref: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T2w.nii.gz
crop_refT1w: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_T1w.nii.gz
Mask_crop: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-{hemi}_space-corobl_desc-hipp_mask.nii.gz
dseg: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_hemi-R_space-corobl_desc-tissue_dseg.nii.gz
coords: resources/templates-3d/tpl-MBMv3/tpl-MBMv3_dir-{dir}_hemi-R_space-corobl_label-{autotop}_desc-laplace_coords.nii.gz
upenn:
T1w: templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
dseg: templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: templates-3d/tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz
dseg: resources/templates-3d/tpl-upenn/tpl-upenn_desc-hipptissue_dseg.nii.gz
coords: resources/templates-3d/tpl-upenn/tpl-upenn_dir-{dir}_label-{autotop}_coords.nii.gz





Expand All @@ -409,20 +410,20 @@ atlas:

atlas_files:
multihist7:
label_nii: atlases-unfolded/multihist7/sub-maxprob_label-hipp_desc-manualsubfieldsunfoldaligned_dseg.nii.gz
label_list: atlases-unfolded/multihist7/labellist.txt
thick: atlases-unfolded/multihist7/thickness.nii.gz
curv: atlases-unfolded/multihist7/curvature.nii.gz
gyr: atlases-unfolded/multihist7/gyrification.nii.gz
label_nii: resources/atlases-unfolded/multihist7/sub-maxprob_label-hipp_desc-manualsubfieldsunfoldaligned_dseg.nii.gz
label_list: resources/atlases-unfolded/multihist7/labellist.txt
thick: resources/atlases-unfolded/multihist7/thickness.nii.gz
curv: resources/atlases-unfolded/multihist7/curvature.nii.gz
gyr: resources/atlases-unfolded/multihist7/gyrification.nii.gz
bigbrain:
label_nii: atlases-unfolded/bigbrain/sub-bigbrain_hemi-{hemi}_label-hipp_desc-manualsubfields_dseg.nii.gz
label_list: atlases-unfolded/bigbrain/sub-bigbrain_labellist.txt
label_nii: resources/atlases-unfolded/bigbrain/sub-bigbrain_hemi-{hemi}_label-hipp_desc-manualsubfields_dseg.nii.gz
label_list: resources/atlases-unfolded/bigbrain/sub-bigbrain_labellist.txt
magdeburg:
label_nii: atlases-unfolded/magdeburg/sub-all_hemi-{hemi}_label-hipp_desc-manualsubfields_maxprob.nii.gz
label_list: atlases-unfolded/magdeburg/magdeburg_labellist.txt
label_nii: resources/atlases-unfolded/magdeburg/sub-all_hemi-{hemi}_label-hipp_desc-manualsubfields_maxprob.nii.gz
label_list: resources/atlases-unfolded/magdeburg/magdeburg_labellist.txt
freesurfer:
label_nii: atlases-unfolded/freesurfer/sub-all_hemi-{hemi}_space-unfold_label-hipp_desc-freesurfersubfields_dseg.nii.gz
label_list: atlases-unfolded/freesurfer/freesurfer_labellist.txt
label_nii: resources/atlases-unfolded/freesurfer/sub-all_hemi-{hemi}_space-unfold_label-hipp_desc-freesurfersubfields_dseg.nii.gz
label_list: resources/atlases-unfolded/freesurfer/freesurfer_labellist.txt


inject_template: upenn
Expand Down Expand Up @@ -461,7 +462,7 @@ modality: T2w



#these will be downloaded to ~/.cache/hippunfold or $HIPPUNFOLD_CACHE_DIR
#these will be downloaded to ~/.cache/hippunfold
nnunet_model:
T1w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task101_hcp1200_T1w.nnUNetTrainerV2.model_best.tar'
T2w: 'zenodo.org/record/4508747/files/trained_model.3d_fullres.Task102_hcp1200_T2w.nnUNetTrainerV2.model_best.tar'
Expand All @@ -472,21 +473,6 @@ nnunet_model:
synthseg_v0.1: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task102_synsegGenDetailed.nnUNetTrainerV2.model_best.tar'
synthseg_v0.2: 'zenodo.org/record/8184230/files/trained_model.3d_fullres.Task203_synthseg.nnUNetTrainerV2.model_best.tar'

atlas_files_osf:
multihist7: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b782827451220b86dd8/?zip='
bigbrain: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8b13d27b123094c96f/?zip='
magdeburg: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8013d27b122f94c938/?zip='
freesurfer: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395b8513d27b123094c96a/?zip='
#https://github.com/CenterForOpenScience/osf.io/issues/8256#issuecomment-379833911

template_files_osf:
CITI168: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395bf0282745121fb86a93/?zip='
dHCP: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395bff13d27b123094c9b4/?zip='
MBMv2: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395c0887852d133ca597dd/?zip='
MBMv3: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395c0e8a28b11240ffc6e9/?zip='
upenn: 'https://files.ca-1.osf.io/v1/resources/v8acf/providers/osfstorage/65395c1613d27b122a94ca09/?zip='
#https://github.com/CenterForOpenScience/osf.io/issues/8256#issuecomment-379833911

crop_native_box: '256x256x256vox'
crop_native_res: '0.2x0.2x0.2mm'

Expand Down
84 changes: 84 additions & 0 deletions hippunfold/download_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python3
import argparse
import errno
import os

import requests
import yaml
from appdirs import AppDirs


def get_model_dict():
# get list of model urls
model_cfg = os.path.join(
os.path.dirname(__file__), "config", "nnunet_model_urls.yml"
)
with open(model_cfg, "r") as cfg:
model_dict = yaml.load(cfg, Loader=yaml.FullLoader)
return model_dict


def parse_args(model_dict):
parser = argparse.ArgumentParser(
prog="hippunfold_download_models",
description="Tool for downloading U-net models for hippunfold",
)

parser.add_argument("--models", nargs="+", dest="models", choices=model_dict.keys())
args = parser.parse_args()
return args


def main():

# get the model dict first, so we know what to parse
model_dict = get_model_dict()
inputs = parse_args(model_dict)

if "HIPPUNFOLD_CACHE_DIR" in os.environ.keys():
print(
f"HIPPUNFOLD_CACHE_DIR defined, using: {os.environ['HIPPUNFOLD_CACHE_DIR']}"
)
download_dir = os.environ["HIPPUNFOLD_CACHE_DIR"]
else:
print(f"HIPPUNFOLD_CACHE_DIR not defined, using default location")
# create local download dir if it doesn't exist
dirs = AppDirs("hippunfold", "khanlab")
download_dir = dirs.user_cache_dir

try:
os.mkdir(download_dir)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
pass

if inputs.models == None:
models = model_dict.keys()
else:
models = inputs.models

for modality in models:
url = model_dict[modality]
tarfile = url.split("/")[-1]
local_path = os.path.join(download_dir, tarfile)

# add ?dl=1 to url
url = "".join([url, "?dl=1"])

# if it doesn't exist, download the file
if not os.path.exists(local_path):
# download it:
print(f"Downloading {modality} model...")
print(f" url = {url}")
print(f" dest = {local_path}")
r = requests.get(url, allow_redirects=True, stream=True)
with open(local_path, "wb") as f:
f.write(r.content)
print(" Download complete")
else:
print(f"Skipping {modality} model: already downloaded to {local_path}")


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
################################################
# ITK-SnAP Label Description File
# File format:
# IDX -R- -G- -B- -A-- VIS MSH LABEL
# Fields:
# IDX: Zero-based index
# -R-: Red color component (0..255)
# -G-: Green color component (0..255)
# -B-: Blue color component (0..255)
# -A-: Label transparency (0.00 .. 1.00)
# VIS: Label visibility (0 or 1)
# IDX: Label mesh visibility (0 or 1)
# LABEL: Label description
################################################
0 0 0 0 0 0 0 "Clear Label"
1 255 0 0 1 1 1 "Subiculum"
2 0 255 0 1 1 1 "CA1"
3 0 0 255 1 1 1 "CA2"
4 255 255 0 1 1 1 "CA3"
5 0 255 255 1 1 1 "CA4"
6 255 0 255 1 1 1 "DG"
7 255 239 213 1 1 1 "SRLM"
8 240 86 224 1 1 1 "Cyst"

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
index name abbreviation
1 subiculum Sub
2 CA1 CA1
3 CA2 CA2
4 CA3 CA3
5 CA4 CA4
6 dentate_gyrus DG
7 SRLM SRLM
8 cysts Cyst
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Subiculum
1 0 0 255 255
CA1
2 133 222 255 255
CA2
3 0 255 170 255
CA3
4 255 162 0 255
CA4
5 255 0 0 255
6 changes: 6 additions & 0 deletions hippunfold/resources/atlases-unfolded/freesurfer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Freesurfer subfield atlas

Generated using workflow from https://github.com/khanlab/hippunfold-create-atlas#freesurfer
This creates probalistic and maxprob (used here) labels by running hippunfold & freesurfer subfield segmentation on ds002168 (openneuro, 48 subjects) and mapping the freesurfer labels to the unfolded space.


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
index name abbreviation
203 parasubiculum ParaSub
204 presubiculum PreSub
205 subiculum Sub
206 CA1 CA1
208 CA3 CA3
209 CA4_and_dentate gyrus CA4_DG
226 tail Tail
227 SRLM SRLM
228 cysts Cyst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#No. Label Name R G B A
1 subiculum 255 0 0 0
2 CA1 0 255 0 0
3 CA2 0 0 255 0
4 CA3 255 255 0 0
5 CA4 0 255 255 0
6 dentate_gyrus 255 0 255 0
7 SRLM 255 239 213 0
8 cysts 0 0 205 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
alveus
201 255 204 153 255
perforant_pathway
202 255 128 128 255
parasubiculum
203 175 175 75 255
presubiculum
204 64 0 64 255
subiculum
205 0 0 255 255
CA1
206 255 0 0 255
CA2
207 128 128 255 255
CA3
208 0 128 0 255
CA4
209 196 160 128 255
GC-DG
210 32 200 255 255
HATA
211 128 255 128 255
fimbria
212 204 153 204 255
lateral_ventricle
213 121 17 136 255
molecular_layer_HP
214 128 0 0 255
hippocampal_fissure
215 128 32 255 255
entorhinal_cortex
216 255 204 102 255
molecular_layer_subiculum
217 128 128 128 255
Amygdala
218 104 255 255 255
Cerebral_White_Matter
219 0 226 0 255
Cerebral_Cortex
220 205 63 78 255
Inf_Lat_Vent
221 197 58 250 255
Perirhinal
222 33 150 250 255
Cerebral_White_Matter_Edge
223 226 0 0 255
Background
224 100 100 100 255
Ectorhinal
225 197 150 250 255
HP_tail
226 170 170 255 255
Polymorphic-Layer
227 128 255 128 255
Intracellular-Space
228 204 153 204 255
HP_body
231 0 255 0 255
HP_head
232 255 0 0 255
presubiculum-head
233 32 0 32 255
presubiculum-body
234 64 0 64 255
subiculum-head
235 0 0 175 255
subiculum-body
236 0 0 255 255
CA1-head
237 175 75 75 255
CA1-body
238 255 0 0 255
CA3-head
239 0 80 0 255
CA3-body
240 0 128 0 255
CA4-head
241 120 90 50 255
CA4-body
242 196 160 128 255
GC-ML-DG-head
243 75 125 175 255
GC-ML-DG-body
244 32 200 255 255
molecular_layer_HP-head
245 100 25 25 255
molecular_layer_HP-body
246 128 0 0 255
Loading

0 comments on commit ccf04a6

Please sign in to comment.