-
Notifications
You must be signed in to change notification settings - Fork 18
/
getPretrainedNetwork.R
283 lines (278 loc) · 14.9 KB
/
getPretrainedNetwork.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#' getPretrainedNetwork
#'
#' Downloads pretrained network/weights.
#'
#' @param fileId one of the permitted file ids or pass "show" to list all
#' valid possibilities. Note that most require internet access to download.
#' @param targetFileName optional target filename
#' @param antsxnetCacheDirectory destination directory for storing the downloaded
#' template and model weights. Since these can be resused, if
#' \code{is.null(antsxnetCacheDirectory)}, these data will be downloaded to the
#' subdirectory ~/.keras/ANTsXNet/.
#' @return filename string
#' @author Avants BB
#' @note See \url{https://figshare.com/authors/Nick_Tustison/441144}
#' or \url{https://figshare.com/authors/Brian_Avants/418551}
#' for some more descriptions
#' @examples
#' \dontrun{
#' net <- getPretrainedNetwork( "dbpn4x" )
#' }
#' @export getPretrainedNetwork
getPretrainedNetwork <- function(
fileId = c( "show",
"antsxnetWmh",
"antsxnetWmhOr",
"arterialLesionWeibinShi",
"brainAgeGender",
"brainAgeFmrib",
"brainAgeDeepBrainNet",
"brainExtraction",
"brainExtractionT1",
"brainExtractionT1v1",
"brainExtractionRobustT1",
"brainExtractionT2",
"brainExtractionRobustT2",
"brainExtractionRobustT2Star",
"brainExtractionFLAIR",
"brainExtractionRobustFLAIR",
"brainExtractionBOLD",
"brainExtractionRobustBOLD",
"brainExtractionFA",
"brainExtractionMra",
"brainExtractionRobustFA",
"brainExtractionNoBrainer",
"brainExtractionInfantT1T2",
"brainExtractionInfantT1",
"brainExtractionInfantT2",
"brainSegmentation",
"brainSegmentationPatchBased",
"bratsStage1",
"bratsStage2",
"cerebellumWhole",
"cerebellumTissue",
"cerebellumLabels",
"claustrum_axial_0",
"claustrum_axial_1",
"claustrum_axial_2",
"claustrum_coronal_0",
"claustrum_coronal_1",
"claustrum_coronal_2",
"ctHumanLung",
"dbpn4x",
"deepFlash",
"deepFlashLeftT1",
"deepFlashRightT1",
"deepFlashLeftBoth",
"deepFlashRightBoth",
"deepFlashLeftT1Hierarchical",
"deepFlashRightT1Hierarchical",
"deepFlashLeftBothHierarchical",
"deepFlashRightBothHierarchical",
"deepFlashLeftT1Hierarchical_ri",
"deepFlashRightT1Hierarchical_ri",
"deepFlashLeftBothHierarchical_ri",
"deepFlashRightBothHierarchical_ri",
"deepFlashLeft8",
"deepFlashRight8",
"deepFlashLeft16",
"deepFlashRight16",
"deepFlashLeft16new",
"deepFlashRight16new",
"denoising",
"dktInner",
"dktOuter",
"dktOuterWithSpatialPriors",
"ex5_coronal_weights",
"ex5_sagittal_weights",
"allen_brain_mask_weights",
"functionalLungMri",
"hippMapp3rInitial",
"hippMapp3rRefine",
"hyperMapp3r",
"hypothalamus",
"inpainting_sagittal_rmnet_weights",
"inpainting_coronal_rmnet_weights",
"inpainting_axial_rmnet_weights",
"inpainting_axial_rmnet_flair_weights",
"inpainting_coronal_rmnet_flair_weights",
"inpainting_sagittal_rmnet_flair_weights",
"koniqMBCS",
"koniqMS",
"koniqMS2",
"koniqMS3",
"lesion_whole_brain",
"lungCtWithPriorsSegmentationWeights",
"maskLobes",
"mriSuperResolution",
"mriModalityClassification",
"mraVesselWeights_160",
"mouseMriBrainExtraction",
"mouseT2wBrainExtraction3D",
"mouseT2wBrainParcellation3DNick",
"mouseSTPTBrainParcellation3DJay",
"protonLungMri",
"protonLobes",
"pulmonaryArteryWeights",
"pulmonaryAirwayWeights",
"sixTissueOctantBrainSegmentation",
"sixTissueOctantBrainSegmentationWithPriors1",
"sixTissueOctantBrainSegmentationWithPriors2",
"sysuMediaWmhFlairOnlyModel0",
"sysuMediaWmhFlairOnlyModel1",
"sysuMediaWmhFlairOnlyModel2",
"sysuMediaWmhFlairT1Model0",
"sysuMediaWmhFlairT1Model1",
"sysuMediaWmhFlairT1Model2",
"tidsQualityAssessment",
"xrayLungOrientation",
"xrayLungExtraction",
"chexnetClassificationModel",
"chexnetClassificationANTsXNetModel",
"tb_antsxnet_model",
"wholeHeadInpaintingFLAIR",
"wholeHeadInpaintingPatchBasedT1",
"wholeHeadInpaintingPatchBasedFLAIR",
"wholeTumorSegmentationT2Flair",
"wholeLungMaskFromVentilation" ),
targetFileName, antsxnetCacheDirectory = NULL )
{
if( fileId[1] == "show" )
{
return( fileId )
}
fileId = match.arg( fileId )
url <- switch(
fileId,
antsxnetWmh = "https://figshare.com/ndownloader/files/42301059",
antsxnetWmhOr = "https://figshare.com/ndownloader/files/42301056",
arterialLesionWeibinShi = "https://figshare.com/ndownloader/files/31624922",
brainAgeGender = "https://ndownloader.figshare.com/files/22179948",
brainAgeFmrib = "https://ndownloader.figshare.com/files/22429077",
brainAgeDeepBrainNet = "https://ndownloader.figshare.com/files/23573402",
brainExtraction = "https://ndownloader.figshare.com/files/22944632",
brainExtractionT1 = "https://ndownloader.figshare.com/files/27334370",
brainExtractionT1v1 = "https://ndownloader.figshare.com/files/28057626",
brainExtractionRobustT1 = "https://figshare.com/ndownloader/files/34821874",
brainExtractionT2 = "https://ndownloader.figshare.com/files/23066153",
brainExtractionRobustT2 = "https://figshare.com/ndownloader/files/34870416",
brainExtractionRobustT2Star = "https://figshare.com/ndownloader/files/34870413",
brainExtractionFLAIR = "https://ndownloader.figshare.com/files/23562194",
brainExtractionRobustFLAIR = "https://figshare.com/ndownloader/files/34870407",
brainExtractionBOLD = "https://ndownloader.figshare.com/files/22761977",
brainExtractionRobustBOLD = "https://figshare.com/ndownloader/files/34870404",
brainExtractionFA = "https://ndownloader.figshare.com/files/22761926",
brainExtractionRobustFA = "https://figshare.com/ndownloader/files/34870410",
brainExtractionMra = "https://figshare.com/ndownloader/files/46335052",
brainExtractionNoBrainer = "https://ndownloader.figshare.com/files/22598039",
brainExtractionInfantT1T2 = "https://ndownloader.figshare.com/files/22968833",
brainExtractionInfantT1 = "https://ndownloader.figshare.com/files/22968836",
brainExtractionInfantT2 = "https://ndownloader.figshare.com/files/22968830",
brainSegmentation = "https://ndownloader.figshare.com/files/13900010",
brainSegmentationPatchBased = "https://ndownloader.figshare.com/files/14249717",
bratsStage1 = "https://figshare.com/ndownloader/files/42384756",
bratsStage2 = "https://figshare.com/ndownloader/files/42685150", # "https://figshare.com/ndownloader/files/42384750",
cerebellumWhole = "https://figshare.com/ndownloader/files/41460447",
cerebellumTissue = "https://figshare.com/ndownloader/files/41107724",
cerebellumLabels = "https://figshare.com/ndownloader/files/41168678",
claustrum_axial_0 = "https://ndownloader.figshare.com/files/27844068",
claustrum_axial_1 = "https://ndownloader.figshare.com/files/27844059",
claustrum_axial_2 = "https://ndownloader.figshare.com/files/27844062",
claustrum_coronal_0 = "https://ndownloader.figshare.com/files/27844074",
claustrum_coronal_1 = "https://ndownloader.figshare.com/files/27844071",
claustrum_coronal_2 = "https://ndownloader.figshare.com/files/27844065",
ctHumanLung = "https://ndownloader.figshare.com/files/20005217",
dbpn4x = "https://figshare.com/ndownloader/files/35295394",
deepFlash = "https://ndownloader.figshare.com/files/22933757",
deepFlashLeft8 = "https://ndownloader.figshare.com/files/25441007",
deepFlashRight8 = "https://ndownloader.figshare.com/files/25441004",
deepFlashLeft16 = "https://ndownloader.figshare.com/files/25465844",
deepFlashRight16 = "https://ndownloader.figshare.com/files/25465847",
deepFlashLeft16new = "https://ndownloader.figshare.com/files/25991681",
deepFlashRight16new = "https://ndownloader.figshare.com/files/25991678",
deepFlashLeftT1 = "https://ndownloader.figshare.com/files/28966269",
deepFlashRightT1 = "https://ndownloader.figshare.com/files/28966266",
deepFlashLeftBoth = "https://ndownloader.figshare.com/files/28966275",
deepFlashRightBoth = "https://ndownloader.figshare.com/files/28966272",
deepFlashLeftT1Hierarchical = "https://figshare.com/ndownloader/files/31226449",
deepFlashRightT1Hierarchical = "https://figshare.com/ndownloader/files/31226452",
deepFlashLeftBothHierarchical = "https://figshare.com/ndownloader/files/31226458",
deepFlashRightBothHierarchical = "https://figshare.com/ndownloader/files/31226455",
deepFlashLeftT1Hierarchical_ri = "https://figshare.com/ndownloader/files/33198794",
deepFlashRightT1Hierarchical_ri = "https://figshare.com/ndownloader/files/33198800",
deepFlashLeftBothHierarchical_ri = "https://figshare.com/ndownloader/files/33198803",
deepFlashRightBothHierarchical_ri = "https://figshare.com/ndownloader/files/33198809",
denoising = "https://ndownloader.figshare.com/files/14235296",
dktInner = "https://ndownloader.figshare.com/files/23266943",
dktOuter = "https://ndownloader.figshare.com/files/23765132",
dktOuterWithSpatialPriors = "https://ndownloader.figshare.com/files/24230768",
e13x5_coronal_weights = "https://figshare.com/ndownloader/files/38035968",
e13x5_sagittal_weights = "https://figshare.com/ndownloader/files/38035965",
allen_brain_mask_weights = "https://figshare.com/ndownloader/files/36999880",
elBicho = "https://ndownloader.figshare.com/files/26736779",
functionalLungMri = "https://ndownloader.figshare.com/files/13824167",
hippMapp3rInitial = "https://ndownloader.figshare.com/files/18068408",
hippMapp3rRefine = "https://ndownloader.figshare.com/files/18068411",
hyperMapp3r = "https://figshare.com/ndownloader/files/38790702",
hypothalamus = "https://ndownloader.figshare.com/files/28344378",
inpainting_sagittal_rmnet_weights = "https://figshare.com/ndownloader/files/44367188",
inpainting_coronal_rmnet_weights = "https://figshare.com/ndownloader/files/44294099",
inpainting_axial_rmnet_weights = "https://figshare.com/ndownloader/files/44244446",
inpainting_axial_rmnet_flair_weights = "https://figshare.com/ndownloader/files/44406923",
inpainting_coronal_rmnet_flair_weights = "https://figshare.com/ndownloader/files/44468984",
inpainting_sagittal_rmnet_flair_weights = "https://figshare.com/ndownloader/files/44511356",
koniqMBCS = "https://ndownloader.figshare.com/files/24967376",
koniqMS = "https://figshare.com/ndownloader/files/35295403",
koniqMS2 = "https://figshare.com/ndownloader/files/35295397",
koniqMS3 = "https://figshare.com/ndownloader/files/35295400",
lesion_whole_brain = "https://figshare.com/ndownloader/files/44032017", # 44162156
lungCtWithPriorsSegmentationWeights = "https://ndownloader.figshare.com/files/28357818",
maskLobes = "https://figshare.com/ndownloader/files/30678458",
mriSuperResolution = "https://figshare.com/ndownloader/files/35290684",
mriModalityClassification = "https://figshare.com/ndownloader/files/41691681",
mraVesselWeights_160 = "https://figshare.com/ndownloader/files/46406029",
mouseMriBrainExtraction = "https://figshare.com/ndownloader/files/44714947",
mouseT2wBrainExtraction3D = "https://figshare.com/ndownloader/files/44943715",
mouseT2wBrainParcellation3DNick = "https://figshare.com/ndownloader/files/44714944",
mouseSTPTBrainParcellation3DJay = "https://figshare.com/ndownloader/files/46710592",
protonLungMri = "https://ndownloader.figshare.com/files/13606799",
protonLobes = "https://figshare.com/ndownloader/files/30678455",
pulmonaryAirwayWeights = "https://figshare.com/ndownloader/files/45187168",
pulmonaryArteryWeights = "https://figshare.com/ndownloader/files/46400752",
sixTissueOctantBrainSegmentation = "https://ndownloader.figshare.com/files/23776025",
sixTissueOctantBrainSegmentationWithPriors1 = "https://ndownloader.figshare.com/files/28159869",
sysuMediaWmhFlairOnlyModel0 = "https://ndownloader.figshare.com/files/22898441",
sysuMediaWmhFlairOnlyModel1 = "https://ndownloader.figshare.com/files/22898570",
sysuMediaWmhFlairOnlyModel2 = "https://ndownloader.figshare.com/files/22898438",
sysuMediaWmhFlairT1Model0 = "https://ndownloader.figshare.com/files/22898450",
sysuMediaWmhFlairT1Model1 = "https://ndownloader.figshare.com/files/22898453",
sysuMediaWmhFlairT1Model2 = "https://ndownloader.figshare.com/files/22898459",
tidsQualityAssessment = "https://figshare.com/ndownloader/files/35295391",
xrayLungOrientation = "https://figshare.com/ndownloader/files/41965821",
xrayLungExtraction = "https://figshare.com/ndownloader/files/41965818",
chexnetClassificationModel = "https://figshare.com/ndownloader/files/42460332",
chexnetClassificationANTsXNetModel = "https://figshare.com/ndownloader/files/42460335",
tb_antsxnet_model = "https://figshare.com/ndownloader/files/45820599",
wholeHeadInpaintingT1 = "https://figshare.com/ndownloader/files/39255422",
wholeHeadInpaintingFLAIR = "https://figshare.com/ndownloader/files/39255419",
wholeHeadInpaintingPatchBasedT1 = "https://figshare.com/ndownloader/files/39337442",
wholeHeadInpaintingPatchBasedFLAIR = "https://figshare.com/ndownloader/files/39337439",
wholeTumorSegmentationT2Flair = "https://ndownloader.figshare.com/files/14087045",
wholeLungMaskFromVentilation = "https://ndownloader.figshare.com/files/28914441"
)
if( missing( targetFileName ) )
{
targetFileName <- paste0( fileId, ".h5" )
}
if( is.null( antsxnetCacheDirectory ) )
{
antsxnetCacheDirectory <- fs::path_join( path.expand( c( "~/.keras/ANTsXNet" ) ) )
}
targetFileNamePath <- fs::path_join( path.expand( c( antsxnetCacheDirectory, targetFileName ) ) )
if( ! fs::file_exists( targetFileNamePath ) )
{
targetFileNamePath <- tensorflow::tf$keras$utils$get_file(
targetFileName, url, cache_subdir = antsxnetCacheDirectory )
}
return( targetFileNamePath )
}