Skip to content

Commit

Permalink
v2023.1.26 Fix Flywheel folder handling for Web vs CLI downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
jmtyszka committed Jan 26, 2023
1 parent 357f003 commit 5f7f3db
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# BIDSKIT Changelog

## Version 2023.1.26
- Fixed folder name handling for Web vs CLI Flywheel DICOM downloads

## Version 2023.1.12
- Add support for Flywheel DICOM download curation

## Version 2022.2.1
- Added support for complex-valued, bias corrected and multiecho image types
- Added command line control for rec-, echo- and part- keys in BIDS filenames
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BIDSKIT

### Version 2023.1.12
### Version 2023.1.26
Python utilities for converting from DICOM to BIDS neuroimaging formats.

The *bidskit* console command takes a directory tree containing imaging series from one or more subjects (eg T1w MPRAGE, BOLD EPI, Fieldmaps), converts the imaging data to Nifti-1 format with JSON metadata files (sidecars) and populates a directory tree according to the latest BIDS specification.
Expand Down
20 changes: 16 additions & 4 deletions bidskit/flywheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def unpack(dataset_dir):
src_dir = op.join(dataset_dir, 'sourcedata')
os.makedirs(src_dir, exist_ok=True)

# Look for one or more flywheel tarballs
# Look for one or more flywheel tarballs in the BIDS dataset root folder
fw_tarball_list = sorted(glob(op.join(dataset_dir, 'flywheel_*.tar')))

if len(fw_tarball_list) < 1:
Expand All @@ -50,12 +50,24 @@ def unpack(dataset_dir):
subprocess.run(['tar', 'xf', tb_fname, '-C', src_dir])

# bidskit uses sourcedata/<SUBJECT>/<SESSION> organization
# Flywheel uses sourcedata/flywheel/<GROUP>/<PROJECT>/<SUBJECT>/SESSION>
# Flywheel uses sourcedata/<FWDIRNAME>/<GROUP>/<PROJECT>/<SUBJECT>/SESSION>
# so move <SUBJECT> folder up three levels within sourcedata and
# delete sourcedata/flywheel folder tree
# delete sourcedata/<FWDIRNAME> folder tree
# Currently FWDIRNAME can be either 'flywheel' for web downloads or 'scitran'
# for CLI downloads

# Check for existence of sourcedata/flywheel or sourcedata/scitran folders
# following untarring
fw_web_dir = op.join(src_dir, 'flywheel')
fw_cli_dir = op.join(src_dir, 'scitran')
if op.isdir(fw_web_dir):
fw_dir = fw_web_dir
elif op.isdir(fw_cli_dir):
fw_dir = fw_cli_dir
else:
raise Exception(f'Neither sourcedata/flywheel or sourcedata/scitran exist following tar extraction')

# Assume only one group/project present in sourcedata following tarball unpacking
fw_dir = op.join(src_dir, 'flywheel')
subj_dir_list = sorted(glob(op.join(fw_dir, '*', '*', '*')))
for subj_dir in subj_dir_list:
print(f' Moving {subj_dir} to {src_dir}')
Expand Down
2 changes: 1 addition & 1 deletion docs/Flywheel.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Flywheel allows export of all DICOM data from a project, subject or session from
The data exports to an uncompressed tar archive (*tarball*) with the following example folder organization:

```
flywheel
flywheel or scitran
└── odoherty
└── OLEL
└── JOD_OLEL_031
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# For a discussion on single-sourcing the version across setup.py and the
# project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='2023.1.12', # Required
version='2023.1.26', # Required

# This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field:
Expand Down

0 comments on commit 5f7f3db

Please sign in to comment.