@@ -193,3 +193,52 @@ def _grp_echos(x):
193
193
subj_data .update ({"bold" : ses_uids })
194
194
195
195
return subj_data , layout
196
+
197
+
198
+ def write_derivative_description (bids_dir , deriv_dir ):
199
+ from fmriprep import __version__
200
+
201
+ desc = {
202
+ 'Name' : 'fMRIPrep output' ,
203
+ 'BIDSVersion' : '1.1.1' ,
204
+ 'PipelineDescription' : {
205
+ 'Name' : 'fMRIPrep' ,
206
+ 'Version' : __version__ ,
207
+ # We could parse the version to reference a commit or tag
208
+ 'CodeURL' : 'https://github.com/poldracklab/fmriprep' ,
209
+ },
210
+ 'CodeURL' : 'https://github.com/poldracklab/fmriprep' ,
211
+ 'HowToAcknowledge' : 'https://github.com/poldracklab/fmriprep' ,
212
+ }
213
+
214
+ # Keys that can only be set by environment
215
+ if 'FMRIPREP_DOCKER_TAG' in os .environ :
216
+ desc ['DockerHubContainerTag' ] = os .environ ['FMRIPREP_DOCKER_TAG' ]
217
+ if 'FMRIPREP_SINGULARITY_URL' in os .environ :
218
+ singularity_url = os .environ ['FMRIPREP_SINGULARITY_URL' ]
219
+ desc ['SingularityContainerURL' ] = singularity_url
220
+ try :
221
+ desc ['SingularityContainerMD5' ] = _get_shub_version (singularity_url )
222
+ except ValueError :
223
+ pass
224
+
225
+ # Keys deriving from source dataset
226
+ fname = os .path .join (bids_dir , 'dataset_description.json' )
227
+ if os .path .exists (fname ):
228
+ with open (fname ) as fobj :
229
+ orig_desc = json .load (fobj )
230
+ else :
231
+ orig_desc = {}
232
+
233
+ if 'DatasetDOI' in orig_desc :
234
+ desc ['SourceDatasetsURLs' ] = ['https://doi.org/{}' .format (
235
+ orig_desc ['DatasetDOI' ])]
236
+ if 'License' in orig_desc :
237
+ desc ['License' ] = orig_desc ['License' ]
238
+
239
+ with open (os .path .join (deriv_dir , 'dataset_description.json' ), 'w' ) as fobj :
240
+ json .dump (desc , fobj , indent = 4 )
241
+
242
+
243
+ def _get_shub_version (singularity_url ):
244
+ raise ValueError ("Not yet implemented" )
0 commit comments