Skip to content

Commit

Permalink
RF: Deprecate create-study and replace with a respective procedure. (C…
Browse files Browse the repository at this point in the history
  • Loading branch information
bpoldrack committed Aug 27, 2018
1 parent 63f781a commit 901c80c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions datalad_hirni/commands/create_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def __call__(
from datalad.distribution.dataset import Dataset
from datalad.distribution.install import Install
from datalad.distribution.siblings import Siblings
from datalad.support.exceptions import DeprecatedError

raise DeprecatedError(new="use 'datalad create' and 'datalad "
"run-procedure setup_study_dataset' instead "
"to setup a HIRNI study dataset.",
msg="'hirni-create-study is deprecated.")

import os

Expand Down
54 changes: 54 additions & 0 deletions datalad_hirni/resources/procedures/setup_study_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Procedure to apply a sensible default setup to a study dataset
"""

import sys
from datalad.distribution.dataset import require_dataset

# bound dataset methods
import datalad.distribution.add
import datalad.distribution.save
from datalad.plugin.add_readme import AddReadme

ds = require_dataset(
sys.argv[1],
check_installed=True,
purpose='study dataset setup')


force_in_git = [
'README',
'CHANGES',
'dataset_description.json',
'**/{}'.format(ds.config.get("datalad.hirni.studyspec.filename",
"studyspec.json")),
]

# except for hand-picked global metadata, we want anything
# to go into the annex to be able to retract files after
# publication
ds.repo.set_gitattributes([('**', {'annex.largefiles': 'anything'})])
ds.repo.set_gitattributes([(p, {'annex.largefiles': 'nothing'})
for p in force_in_git])


# TODO:
# Note: This default is using the DICOM's PatientID as the acquisition ID
# (directory name in the study dataset). That approach works for values
# accessible via the DICOM metadata directly. We probably want a way to apply
# more sophisticated rules, which could be achieved by a String Formatter
# providing more sophisticated operations like slicing (prob. to be shared with
# datalad's --output-format logic) or by apply specification rules prior to
# determining final location of the imported subdataset. The latter might lead
# to a mess, since import and specification routines would then be quite
# twisted.
ds.config.add('datalad.hirni.import.acquisition-format',
"{PatientID}", where='dataset')

ds.save(message='[HIRNI] Default study dataset setup')

# Include the most basic README to prevent heudiconv from adding one
ds.add_readme(filename='README', existing='fail')


# TODO: Reconsider using an import container and if so, link it herein. See
# now-deprecated hirni-create-study command

0 comments on commit 901c80c

Please sign in to comment.