antspymm 1.4.5__tar.gz → 1.4.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {antspymm-1.4.5/antspymm.egg-info → antspymm-1.4.6}/PKG-INFO +3 -2
  2. {antspymm-1.4.5 → antspymm-1.4.6}/antspymm/mm.py +1 -0
  3. {antspymm-1.4.5 → antspymm-1.4.6/antspymm.egg-info}/PKG-INFO +3 -2
  4. {antspymm-1.4.5 → antspymm-1.4.6}/antspymm.egg-info/SOURCES.txt +4 -0
  5. antspymm-1.4.6/docs/describe_mm_data.R +144 -0
  6. antspymm-1.4.6/docs/template_overlays.py +17 -0
  7. {antspymm-1.4.5 → antspymm-1.4.6}/pyproject.toml +1 -1
  8. antspymm-1.4.6/tests/perfusion_run_nnl.py +46 -0
  9. antspymm-1.4.6/tests/test_rsfmri_run_minimal_ptbp.py +53 -0
  10. {antspymm-1.4.5 → antspymm-1.4.6}/LICENSE +0 -0
  11. {antspymm-1.4.5 → antspymm-1.4.6}/MANIFEST.in +0 -0
  12. {antspymm-1.4.5 → antspymm-1.4.6}/README.md +0 -0
  13. {antspymm-1.4.5 → antspymm-1.4.6}/antspymm/__init__.py +0 -0
  14. {antspymm-1.4.5 → antspymm-1.4.6}/antspymm.egg-info/dependency_links.txt +0 -0
  15. {antspymm-1.4.5 → antspymm-1.4.6}/antspymm.egg-info/requires.txt +0 -0
  16. {antspymm-1.4.5 → antspymm-1.4.6}/antspymm.egg-info/top_level.txt +0 -0
  17. {antspymm-1.4.5 → antspymm-1.4.6}/docs/adni_rsfmri_2_nrg_conversion.py +0 -0
  18. {antspymm-1.4.5 → antspymm-1.4.6}/docs/antspymm_annotated_output_tree.pages +0 -0
  19. {antspymm-1.4.5 → antspymm-1.4.6}/docs/antspymm_annotated_output_tree.txt +0 -0
  20. {antspymm-1.4.5 → antspymm-1.4.6}/docs/antspymm_data_dictionary.csv +0 -0
  21. {antspymm-1.4.5 → antspymm-1.4.6}/docs/bids_cohort_example.py +0 -0
  22. {antspymm-1.4.5 → antspymm-1.4.6}/docs/blind_qc.Rmd +0 -0
  23. {antspymm-1.4.5 → antspymm-1.4.6}/docs/blind_qc.html +0 -0
  24. {antspymm-1.4.5 → antspymm-1.4.6}/docs/convert_adni_dti_to_nrg.R +0 -0
  25. {antspymm-1.4.5 → antspymm-1.4.6}/docs/deepnbm.jpg +0 -0
  26. {antspymm-1.4.5 → antspymm-1.4.6}/docs/example_antspymm_output.csv +0 -0
  27. {antspymm-1.4.5 → antspymm-1.4.6}/docs/example_run_from_directory.py +0 -0
  28. {antspymm-1.4.5 → antspymm-1.4.6}/docs/make_dict_table.Rmd +0 -0
  29. {antspymm-1.4.5 → antspymm-1.4.6}/docs/make_dict_table.html +0 -0
  30. {antspymm-1.4.5 → antspymm-1.4.6}/docs/nrg_cohort_example.py +0 -0
  31. {antspymm-1.4.5 → antspymm-1.4.6}/docs/ptbp_nrg.py +0 -0
  32. {antspymm-1.4.5 → antspymm-1.4.6}/docs/roi_visualization.py +0 -0
  33. {antspymm-1.4.5 → antspymm-1.4.6}/docs/roi_visualization_ppmi.py +0 -0
  34. {antspymm-1.4.5 → antspymm-1.4.6}/docs/step1_blind_qc.py +0 -0
  35. {antspymm-1.4.5 → antspymm-1.4.6}/docs/step2_outlierness.py +0 -0
  36. {antspymm-1.4.5 → antspymm-1.4.6}/docs/step3_mm_nrg_csv.py +0 -0
  37. {antspymm-1.4.5 → antspymm-1.4.6}/docs/step4_aggregate.py +0 -0
  38. {antspymm-1.4.5 → antspymm-1.4.6}/docs/ukbb_to_nrg_processing.py +0 -0
  39. {antspymm-1.4.5 → antspymm-1.4.6}/docs/ukbb_to_nrg_processing2.py +0 -0
  40. {antspymm-1.4.5 → antspymm-1.4.6}/setup.cfg +0 -0
  41. {antspymm-1.4.5 → antspymm-1.4.6}/tests/bids_2_nrg.py +0 -0
  42. {antspymm-1.4.5 → antspymm-1.4.6}/tests/blind_qc.py +0 -0
  43. {antspymm-1.4.5 → antspymm-1.4.6}/tests/deformation_gradient_reo.py +0 -0
  44. {antspymm-1.4.5 → antspymm-1.4.6}/tests/dti_recon.py +0 -0
  45. {antspymm-1.4.5 → antspymm-1.4.6}/tests/dti_reg.py +0 -0
  46. {antspymm-1.4.5 → antspymm-1.4.6}/tests/dwi_rebasing.py +0 -0
  47. {antspymm-1.4.5 → antspymm-1.4.6}/tests/dwi_run.py +0 -0
  48. {antspymm-1.4.5 → antspymm-1.4.6}/tests/dwi_run_ptbp_scrub.py +0 -0
  49. {antspymm-1.4.5 → antspymm-1.4.6}/tests/flair_run.py +0 -0
  50. {antspymm-1.4.5 → antspymm-1.4.6}/tests/joint_dti_recon.py +0 -0
  51. {antspymm-1.4.5 → antspymm-1.4.6}/tests/mm.py +0 -0
  52. {antspymm-1.4.5 → antspymm-1.4.6}/tests/mm_csv.py +0 -0
  53. {antspymm-1.4.5 → antspymm-1.4.6}/tests/mm_nrg.py +0 -0
  54. {antspymm-1.4.5 → antspymm-1.4.6}/tests/nrg_validation.py +0 -0
  55. {antspymm-1.4.5 → antspymm-1.4.6}/tests/outlierness.py +0 -0
  56. {antspymm-1.4.5 → antspymm-1.4.6}/tests/parallel_study_aggregation_example.py +0 -0
  57. {antspymm-1.4.5 → antspymm-1.4.6}/tests/perfusion_ptbp.py +0 -0
  58. {antspymm-1.4.5 → antspymm-1.4.6}/tests/perfusion_run.py +0 -0
  59. {antspymm-1.4.5 → antspymm-1.4.6}/tests/rsfmri_run.py +0 -0
  60. {antspymm-1.4.5 → antspymm-1.4.6}/tests/rsfmri_run_minimal.py +0 -0
  61. {antspymm-1.4.5 → antspymm-1.4.6}/tests/test_loop.py +0 -0
  62. {antspymm-1.4.5 → antspymm-1.4.6}/tests/test_reference_run.py +0 -0
  63. {antspymm-1.4.5 → antspymm-1.4.6}/tests/testsr.py +0 -0
  64. {antspymm-1.4.5 → antspymm-1.4.6}/tests/ukbb_rsfmri.py +0 -0
  65. {antspymm-1.4.5 → antspymm-1.4.6}/tests/visualize_tractogram.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: antspymm
3
- Version: 1.4.5
3
+ Version: 1.4.6
4
4
  Summary: multi-channel/time-series medical image processing with antspyx
5
5
  Author-email: "Avants, Gosselin, Tustison, Reardon" <stnava@gmail.com>
6
6
  License: Apache 2.0
@@ -19,6 +19,7 @@ Requires-Dist: nibabel
19
19
  Requires-Dist: scipy
20
20
  Requires-Dist: siq
21
21
  Requires-Dist: scikit-learn
22
+ Dynamic: license-file
22
23
 
23
24
  # ANTsPyMM
24
25
 
@@ -5355,6 +5355,7 @@ def PerAF( x, mask, globalmean=True ):
5355
5355
  return outimg
5356
5356
 
5357
5357
 
5358
+
5358
5359
  def resting_state_fmri_networks( fmri, fmri_template, t1, t1segmentation,
5359
5360
  f=[0.03, 0.08],
5360
5361
  FD_threshold=5.0,
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: antspymm
3
- Version: 1.4.5
3
+ Version: 1.4.6
4
4
  Summary: multi-channel/time-series medical image processing with antspyx
5
5
  Author-email: "Avants, Gosselin, Tustison, Reardon" <stnava@gmail.com>
6
6
  License: Apache 2.0
@@ -19,6 +19,7 @@ Requires-Dist: nibabel
19
19
  Requires-Dist: scipy
20
20
  Requires-Dist: siq
21
21
  Requires-Dist: scikit-learn
22
+ Dynamic: license-file
22
23
 
23
24
  # ANTsPyMM
24
25
 
@@ -18,6 +18,7 @@ docs/blind_qc.Rmd
18
18
  docs/blind_qc.html
19
19
  docs/convert_adni_dti_to_nrg.R
20
20
  docs/deepnbm.jpg
21
+ docs/describe_mm_data.R
21
22
  docs/example_antspymm_output.csv
22
23
  docs/example_run_from_directory.py
23
24
  docs/make_dict_table.Rmd
@@ -30,6 +31,7 @@ docs/step1_blind_qc.py
30
31
  docs/step2_outlierness.py
31
32
  docs/step3_mm_nrg_csv.py
32
33
  docs/step4_aggregate.py
34
+ docs/template_overlays.py
33
35
  docs/ukbb_to_nrg_processing.py
34
36
  docs/ukbb_to_nrg_processing2.py
35
37
  tests/bids_2_nrg.py
@@ -50,10 +52,12 @@ tests/outlierness.py
50
52
  tests/parallel_study_aggregation_example.py
51
53
  tests/perfusion_ptbp.py
52
54
  tests/perfusion_run.py
55
+ tests/perfusion_run_nnl.py
53
56
  tests/rsfmri_run.py
54
57
  tests/rsfmri_run_minimal.py
55
58
  tests/test_loop.py
56
59
  tests/test_reference_run.py
60
+ tests/test_rsfmri_run_minimal_ptbp.py
57
61
  tests/testsr.py
58
62
  tests/ukbb_rsfmri.py
59
63
  tests/visualize_tractogram.py
@@ -0,0 +1,144 @@
1
+ # powers points 10.1016/j.conb.2012.12.009
2
+ powers=read.csv("~/.antspymm/powers_mni_itk.csv")
3
+ # 10.1016/j.neuroimage.2008.07.009
4
+ # https://doi.org/10.1016/j.neuroimage.2007.07.053
5
+ jhu=read.csv("~/.antspyt1w/FA_JHU_labels_edited.csv")
6
+ # doi: 10.3389/fnins.2012.00171
7
+ # http://dx.doi.org/10.1016/j.neuroimage.2006.01.021
8
+ dktcsv=read.csv("~/.antspyt1w/dkt.csv")
9
+ dktcsv=dktcsv[dktcsv$Label>0,]
10
+ # hipp https://doi.org/10.1101/2023.01.17.23284693
11
+ hipp=read.csv("~/.antspyt1w/mtl_description.csv")
12
+ hipp$Anatomy=hipp$Description
13
+ hipp$Anatomy=gsub("alEC"," antero-lateral entorhinal cortex",hipp$Anatomy)
14
+ hipp$Anatomy=gsub("pMEC"," postero-medial entorhinal cortex",hipp$Anatomy)
15
+ hipp$Anatomy=gsub("DG"," dentate gyrus",hipp$Anatomy)
16
+ hipp$Anatomy=gsub("CA"," cornu ammonis", hipp$Anatomy)
17
+
18
+ # https://doi.org/10.1101/211201
19
+ cit=read.csv("~/.antspyt1w/CIT168_Reinf_Learn_v1_label_descriptions_pad.csv")
20
+ cit$Anatomy=NA
21
+ cit$Anatomy[ grep("STR_Ca", cit$Description )] = 'caudate'
22
+ cit$Anatomy[ grep("STR_Pu", cit$Description )] = 'putamen'
23
+ cit$Anatomy[ grep("STR_NAC", cit$Description )] = 'Nucleus Accumbens'
24
+ cit$Anatomy[ grep("VTA", cit$Description )] = 'Ventral Tegmental Area'
25
+ cit$Anatomy[ grep("PBP", cit$Description )] = 'Parabrachial Pigmented Nucleus'
26
+ cit$Anatomy[ grep("SNc", cit$Description )] = 'Substantia Nigra pars compacta'
27
+ cit$Anatomy[ grep("SNr", cit$Description )] = 'Substantia Nigra pars reticulated'
28
+ cit$Anatomy[ grep("GPe", cit$Description )] = 'globus pallidus externa'
29
+ cit$Anatomy[ grep("GPi", cit$Description )] = 'globus pallidus interna'
30
+ cit$Anatomy[ grep("RN", cit$Description )] = 'red nucleus'
31
+ cit$Anatomy[ grep("STH", cit$Description )] = 'Subthalamic Nucleus'
32
+ cit$Anatomy[ grep("HTH", cit$Description )] = 'Hypothalamus'
33
+ cit$Anatomy[ grep("HN", cit$Description )] = 'Habenular Nuclei'
34
+ cit$Anatomy[ grep("EXA", cit$Description )] = 'extended amygdala'
35
+ cit$Anatomy[ grep("BNST", cit$Description )] = 'bed nuclei of the stria terminali'
36
+ cit$Anatomy[ grep("MN", cit$Description )] = 'mammillary nucleus'
37
+ cit$Anatomy[ grep("SLEA", cit$Description )] = 'sublenticular extended amygdala'
38
+ cit$Anatomy[ grep("VeP", cit$Description )] = 'ventral pallidum'
39
+
40
+ interpretcnx<-function( x ) {
41
+ breaker=gsub("DTI_cnxcount","",x)
42
+ temp = unlist(strsplit(breaker,"_"))
43
+ ind=temp[1]
44
+ anat=paste( temp[-1],collapse='_')
45
+ return( paste( anat, "to", dktcsv[as.integer(ind),'Description'] ) )
46
+ }
47
+ interpretcnx2<-function( x ) {
48
+ breaker=gsub("DTI_cnxcount","",x)
49
+ temp = unlist(strsplit(breaker,"_"))
50
+ ind=temp[1]
51
+ anat=paste( temp[-1],collapse='_')
52
+ return( dktcsv[as.integer(ind),'Description'] )
53
+ }
54
+ # dd=read.csv("joined_mm_or2.csv")
55
+ zz=data.frame( Label=colnames(dd))
56
+ qcrows=min(grep("RandBasis",zz$Label)):grep("resnetGrade", zz$Label)
57
+ zz$Modality='Other'
58
+ zz[ grep("T1Hier", zz$Label), 'Modality']='T1 hierarchical processing'
59
+ zz[ grep("T1w", zz$Label), 'Modality']='T1 DiReCT thickness processing'
60
+ zz[ grep("DTI", zz$Label), 'Modality']='DTI'
61
+ zz[ grep("NM2DMT", zz$Label), 'Modality']='Neuromelanin'
62
+ zz[ grep("rsfMRI", zz$Label), 'Modality']='restingStatefMRI'
63
+ zz[ grep("lair", zz$Label), 'Modality']='Flair'
64
+ zz[ grep("left", zz$Label), 'side']='left'
65
+ zz[ grep("right", zz$Label), 'side']='right'
66
+ zz$Atlas='ANTs'
67
+ zz[ grep("dkt", zz$Label), 'Atlas']='desikan-killiany-tourville'
68
+ zz[ grep("cnxcou", zz$Label), 'Atlas']='desikan-killiany-tourville'
69
+ zz[ grep("jhu", zz$Label), 'Atlas']='johns hopkins white matter'
70
+ zz[ grep("cit", zz$Label), 'Atlas']='CIT168'
71
+ zz[ grep("nbm", zz$Label), 'Atlas']='BF'
72
+ zz[ grep("ch13", zz$Label), 'Atlas']='BF'
73
+ zz[ grep("mtl", zz$Label), 'Atlas']='MTL'
74
+ zz[ grep("rsfMRI", zz$Label),'Atlas']='power peterson fMRI meta-analyses'
75
+ zz[qcrows,'Atlas']='quality control metrics'
76
+ zz[qcrows,'Measurement']='QC'
77
+ zz$Measurement[ grep("FD", zz$Label)]='motion statistic on framewise displacement'
78
+ zz$Measurement[ grep("thk", zz$Label)]='geometry/thickness'
79
+ zz$Measurement[ grep("area", zz$Label)]='geometry/area'
80
+ zz$Measurement[ grep("vol", zz$Label)]='geometry/volume'
81
+ zz$Measurement[ grep("mean_md", zz$Label)]='mean diffusion'
82
+ zz$Measurement[ grep("mean_fa", zz$Label)]='fractional anisotropy'
83
+ zz$Measurement[ grep("cnx", zz$Label)]='tractography-based connectivity'
84
+ zz$Anatomy = zz$Label
85
+ zz$Anatomy = gsub("_thk_","", zz$Anatomy)
86
+ zz$Anatomy = gsub("_area_","", zz$Anatomy)
87
+ zz$Anatomy = gsub("_volume_","", zz$Anatomy)
88
+ zz$Anatomy = gsub("DTI_cnxcount","", zz$Anatomy)
89
+ zz$Anatomy = gsub("DTI_mean_md","", zz$Anatomy)
90
+ zz$Anatomy = gsub("DTI_mean_fa","", zz$Anatomy)
91
+ zz$Anatomy = gsub("T1Hier_","", zz$Anatomy)
92
+ zz$Anatomy = gsub("T1Hier","", zz$Anatomy)
93
+ # fix dkt
94
+ dktlabs=dktcsv$Description
95
+ dktlabs=gsub("right ","",dktlabs)
96
+ dktlabs=gsub("left ","",dktlabs)
97
+ dktlabs2=gsub(" ","_",dktlabs)
98
+ for ( k in 1:length(dktlabs) ) {
99
+ gg=grep( dktlabs[k], zz$Label)
100
+ zz[ gg, "Atlas"]="desikan-killiany-tourville"
101
+ zz[ gg, "Anatomy"]=dktlabs[k]
102
+ gg=grep( dktlabs2[k], zz$Label)
103
+ zz[ gg, "Atlas"]="desikan-killiany-tourville"
104
+ zz[ gg, "Anatomy"]=dktlabs[k]
105
+ }
106
+
107
+ # fix cit
108
+ citlabs=tolower( cit$Description)
109
+ for ( k in 1:length(citlabs) ) {
110
+ gg=grep( citlabs[k], zz$Label)
111
+ zz[ gg, "Atlas"]="CIT168"
112
+ zz[ gg, "Anatomy"]=cit$Anatomy[k]
113
+ }
114
+ zz$Anatomy = gsub("DTIfa","", zz$Anatomy)
115
+ zz$Anatomy = gsub("DTImd","", zz$Anatomy)
116
+ zz$Anatomy = gsub("dktregions","", zz$Anatomy)
117
+ zz$Anatomy = gsub("dktcortex"," cortex only ", zz$Anatomy)
118
+ zz$Anatomy = gsub("_right_","", zz$Anatomy)
119
+ zz$Anatomy = gsub("_left_","", zz$Anatomy)
120
+ zz$Anatomy = gsub("right","", zz$Anatomy)
121
+ zz$Anatomy = gsub("left","", zz$Anatomy)
122
+ zz$Anatomy = gsub("jhu_icbm_labels_1mm","", zz$Anatomy)
123
+ zz[ grep("u_hier_id", zz$Label), -1 ]='unique id'
124
+ cnxrows=grep("DTI_cnxcount",zz$Label)
125
+ for ( k in cnxrows )
126
+ zz$Anatomy[k]=interpretcnx( zz[k,'Label'] )
127
+
128
+ zz[ multigrep( c("rsfMRI","R"), zz$Label, intersect=TRUE), 'side' ]='right'
129
+ zz[ multigrep( c("rsfMRI","L"), zz$Label, intersect=TRUE), 'side' ]='left'
130
+ zz$Measurement[ multigrep( c("rsfMRI","_2_"), zz$Label, intersect=TRUE) ]='network correlation'
131
+ zz$Measurement[ multigrep(c("rsfMRI","_alff"), zz$Label, intersect=TRUE) ]='amplitude of low frequency fluctuations ALFF'
132
+ zz$Measurement[ multigrep( c("rsfMRI","_falff"), zz$Label, intersect=TRUE) ]='fractional amplitude of low frequency fluctuations fALFF'
133
+ zz$Anatomy = gsub("rsfMRI_", "", zz$Anatomy )
134
+ zz$Anatomy = gsub("falffPoint", "", zz$Anatomy )
135
+ zz$Anatomy = gsub("alffPoint", "", zz$Anatomy )
136
+ noncnx=1:1888
137
+ for ( k in sample(noncnx, 3) ) print( zz[k,c("Label","Atlas","Anatomy")] )
138
+
139
+ zz[ zz$Label == 'Flair', 'Measurement' ]='white matter hyper-intensity'
140
+ zz[ zz$Label == 'T2Flair_flair_wmh_prior', 'Measurement' ]='prior-constrained white matter hyper-intensity'
141
+
142
+ zz[ multigrep( c("NM2DMT", "q0pt"), zz$Label, intersect=TRUE), "Measurement" ]='neuromelanin intensity quantile'
143
+
144
+ write.csv( zz, "~/code/ANTsPyMM/antspymm_data_dictionary.csv", row.names=FALSE)
@@ -0,0 +1,17 @@
1
+
2
+ ######## template figures ########
3
+ import ants
4
+ import antspymm
5
+ import pandas as pd
6
+ # Example Usage
7
+ scalar_label_df = pd.DataFrame({'label': range(33), 'scalar_value': range(33)})
8
+ prefix = '../PPMI_template0_'
9
+ print("begin")
10
+ for t in ['mtl','bf','jhuwm','cerebellum','cit168']:
11
+ print( t )
12
+ proimgs=antspymm.template_figure_with_overlay(scalar_label_df, prefix, template=t, outputfilename='/tmp/py_viz_'+t+'.png' )
13
+ t='ctx'
14
+ scalar_label_df = pd.DataFrame({'label': range(1001,1200), 'scalar_value': range(1001,1200)})
15
+ proimgs=antspymm.template_figure_with_overlay(scalar_label_df, prefix, template=t, mask_dilation=0, outputfilename='/tmp/py_viz_'+t+'.png')
16
+
17
+
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "antspymm"
7
- version = "1.4.5"
7
+ version = "1.4.6"
8
8
  description = "multi-channel/time-series medical image processing with antspyx"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -0,0 +1,46 @@
1
+ import sys, os
2
+ import unittest
3
+
4
+ os.environ["TF_NUM_INTEROP_THREADS"] = "8"
5
+ os.environ["TF_NUM_INTRAOP_THREADS"] = "8"
6
+ os.environ["ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"] = "8"
7
+
8
+ import tempfile
9
+ import shutil
10
+ import tensorflow as tf
11
+ import antspymm
12
+ import antspyt1w
13
+ import antspynet
14
+ import ants
15
+ import numpy as np
16
+ from scipy.stats import median_abs_deviation
17
+ import math
18
+
19
+ islocal = False
20
+ t1fn = '/Users/stnava/code/NNL/data/sub-1001-0462_run-001_t1.nii.gz'
21
+ ffn='/Users/stnava/code/NNL/data/sub-1001-0462_run-001_perf.nii.gz'
22
+ fmri = ants.image_read( ffn )
23
+ #dkt
24
+ if not 'dkt' in globals():
25
+ t1head = ants.image_read( t1fn ).n3_bias_field_correction( 8 ).n3_bias_field_correction( 4 )
26
+ t1bxt = antspynet.brain_extraction( t1head, 't1' ).threshold_image( 0.3, 1.0 )
27
+ t1 = t1bxt * t1head
28
+ t1seg = antspynet.deep_atropos( t1head )
29
+ t1segmentation = t1seg['segmentation_image']
30
+ dkt = antspynet.desikan_killiany_tourville_labeling( t1head )
31
+ #################
32
+
33
+ #################
34
+ type_of_transform='Rigid'
35
+ tc='alternating'
36
+ fmri_template, hlinds = antspymm.loop_timeseries_censoring( fmri, 0.1 )
37
+ fmri_template = ants.get_average_of_timeseries( fmri_template )
38
+ print("do perf")
39
+ olthresh=0.2
40
+ perf = antspymm.bold_perfusion( fmri, fmri_template, t1head, t1,
41
+ t1segmentation, dkt, nc=4, type_of_transform=type_of_transform,
42
+ spa=(0.,0.,0.,0.),
43
+ outlier_threshold=olthresh, add_FD_to_nuisance=False, verbose=True )
44
+ ants.image_write( ants.iMath( perf['perfusion'], "Normalize" ), '/tmp/temp.nii.gz' )
45
+ ants.image_write( perf['motion_corrected'], '/tmp/temp2.nii.gz' )
46
+ ants.plot( ants.iMath( perf['perfusion'], "Normalize" ), axis=2, crop=True )
@@ -0,0 +1,53 @@
1
+ import sys, os
2
+ import unittest
3
+
4
+ os.environ["TF_NUM_INTEROP_THREADS"] = "8"
5
+ os.environ["TF_NUM_INTRAOP_THREADS"] = "8"
6
+ os.environ["ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"] = "8"
7
+
8
+ import tempfile
9
+ import shutil
10
+ import tensorflow as tf
11
+ import antspymm
12
+ import antspyt1w
13
+ import antspynet
14
+ import ants
15
+ import numpy as np
16
+ import math
17
+ import glob
18
+
19
+ testingClass = unittest.TestCase( )
20
+ id = 'PEDS131'; dt = '20130816' # high motion - bad volumes
21
+ id = "PEDS074"; dt = "20110803" # high motion - bad volumes
22
+ # id = 'PEDS144'; dt = '20131212' # not so bad
23
+ # id = "PEDS107"; dt = "20130118" # challenging
24
+ prefix = "/Users/stnava/data/PTBP/images/" + id + "/" + dt
25
+ bold = glob.glob( prefix + '/BOLD/' + id + "_" + dt + "*bold*nii.gz" )
26
+ t1w = glob.glob( prefix + '/Anatomy/' + id + "_" + dt + "*t1.nii.gz" )
27
+ rsfn = bold[0]
28
+ print( rsfn )
29
+ t1fn = t1w[0]
30
+ import pandas as pd
31
+ print("do t1")
32
+ if not "t1" in globals():
33
+ t1 = ants.image_read( t1fn ).n3_bias_field_correction( 8 ).n3_bias_field_correction( 4 )
34
+ t1bxt = antspynet.brain_extraction( t1, 't1' ).threshold_image( 0.3, 1.0 )
35
+ t1seg = antspynet.deep_atropos( t1 )
36
+ t1segmentation = t1seg['segmentation_image']
37
+
38
+ if not 'rsfpro' in globals():
39
+ print("do rsf: default")
40
+ img1 = ants.image_read( rsfn )
41
+ fmri_template, hlinds = antspymm.loop_timeseries_censoring( img1, 0.1 )
42
+ fmri_template = antspymm.get_average_rsf( fmri_template )
43
+ # img1 = antspymm.remove_volumes_from_timeseries(img1, list(range(55,4000)))
44
+ rsfpro = antspymm.resting_state_fmri_networks(
45
+ img1,
46
+ fmri_template, t1 * t1bxt, t1segmentation,
47
+ verbose=True )
48
+ mm = { 'rsf': rsfpro }
49
+ antspymm.write_mm( '/tmp/RSF', mm )
50
+ ants.plot( rsfpro['fmri_template'], rsfpro[ rsfpro['dfnname']], crop=True, axis=2 )
51
+ ants.plot( rsfpro['fmri_template'], rsfpro['alff'], crop=True, axis=2 )
52
+ ants.plot( rsfpro['fmri_template'], rsfpro['falff'], crop=True, axis=2 )
53
+ ants.plot( rsfpro['fmri_template'], rsfpro['PerAF'], crop=True, axis=2 )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes