Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Adds extraction of physio signals from DICOMs #446

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

pvelasco
Copy link
Contributor

@pvelasco pvelasco commented May 5, 2020

It uses bidsphysio to extract physiological signals from CMRR EPI DICOMs.

It includes regression test

It uses [`bidsphysio`](https://github.com/cbinyu/bidsphysio) to extract physiological signals from CMRR EPI DICOMs.

It includes regression test
@codecov
Copy link

codecov bot commented May 5, 2020

Codecov Report

Attention: Patch coverage is 91.39785% with 8 lines in your changes missing coverage. Please review.

Project coverage is 76.96%. Comparing base (d8e5c5f) to head (15e4a49).
Report is 608 commits behind head on master.

Files Patch % Lines
heudiconv/convert.py 70.58% 5 Missing ⚠️
heudiconv/dicoms.py 66.66% 1 Missing ⚠️
heudiconv/heuristics/bids_PhoenixReport.py 93.33% 1 Missing ⚠️
heudiconv/heuristics/bids_physio.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #446      +/-   ##
==========================================
+ Coverage   76.01%   76.96%   +0.95%     
==========================================
  Files          38       40       +2     
  Lines        3010     3100      +90     
==========================================
+ Hits         2288     2386      +98     
+ Misses        722      714       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet!!!!! Left notes from a very initial cursory review.

Dockerfile Outdated Show resolved Hide resolved
heudiconv/convert.py Show resolved Hide resolved
heudiconv/dicoms.py Outdated Show resolved Hide resolved
heudiconv/tests/test_regression.py Show resolved Hide resolved
heudiconv/tests/test_regression.py Outdated Show resolved Hide resolved
heudiconv/convert.py Outdated Show resolved Hide resolved
Copy link
Member

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is awesome, thank you!

a few style suggestions, though we might just consider blacking the whole repo and adhering to a stricter style guide.

another consideration while looking at this - WDYT about fetching the data via datalad instead of hosting it in the repo?

heudiconv/convert.py Outdated Show resolved Hide resolved
heudiconv/convert.py Outdated Show resolved Hide resolved
heudiconv/convert.py Show resolved Hide resolved
heudiconv/dicoms.py Outdated Show resolved Hide resolved
heudiconv/dicoms.py Outdated Show resolved Hide resolved
@yarikoptic
Copy link
Member

re blacking: I don't mind at all. But we have outstanding sizeable PRs so it would introduce conflicts... will need to check with @tsalo and @bpinsard

@pvelasco
Copy link
Contributor Author

pvelasco commented May 6, 2020

another consideration while looking at this - WDYT about fetching the data via datalad instead of hosting it in the repo?

Of course, that would be great. You can just download the data from my branch, or I can send you a zip file with them. Once they are in DataLad, I'll modify the regression tests accordingly.

@tsalo
Copy link
Member

tsalo commented May 6, 2020

@yarikoptic, I like automated code formatting, but I think running black would introduce a ton of conflicts in #442. Could aggressive re-formatting be something that's done in its own PR after the pending larger PRs are handled?

@mgxd
Copy link
Member

mgxd commented May 6, 2020

of course, it would make it nearly unreviewable! I meant showing some love to formatting prior to the next release, and then inserting a style check into our CI

@yarikoptic
Copy link
Member

Just a note (I am ok either way): theoretically (didn't try yet) if there is no value in individual commits in a or (or if they are way to split from a full diff, eg different files), and both branches are auto blacked when pr branch having master branch merged right before blacking - should be easy to force refresh PRs with blacked version ;-) I can try if we decide to black it all

@yarikoptic
Copy link
Member

Re data - I think it is time to remove the middle man me! Let's (ab)use lfs of GitHub with datalad: http://handbook.datalad.org/en/latest/basics/101-138-sharethirdparty.html?highlight=Lfs#use-github-for-sharing-content . I will initiate a repo with the content of this PR data files, and invite everyone possibly interested ;-)...

@yarikoptic
Copy link
Member

Thinking about it - iirc dicoms compress nicely. I will try with enabling shared encryption - that should compress them while stored in lfs.

To preserve backwards compatibility
To preserve backwards compatibility
…cedata

This way the user can go back to the scanner and import the exact same protocol that was run for a given subject, improving reproducibility.
[`bidsphysio`](https://github.com/cbinyu/bidsphysio) has been refractored into subpackages so that now we only need to import `bidsphysio.dcm2bids`, which has fewer dependencies
yarikoptic and others added 6 commits January 12, 2021 13:34
Merges `adds_acq_time_to_seqinfo` into `dcm_physio` branch
Merge `handles_phoenix_file` into `dcm_physio`
The dependencies for `bidsphysio.dcm2bids>=1.4.3` require Python 3.6 or higher, so don't try to install `bidsphysio.dcm2bids` unless `python_version > 3.5`.
heudiconv/info.py Outdated Show resolved Hide resolved
Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took so long. Did a pass. Also of interest either bidsphysio can convert fresh WiP 1066 Siemens physio data.

edit: I will convert it to draft. Please undraft/ping whenever ready for re-review etc

@@ -461,6 +461,8 @@ def convert(items, converter, scaninfo_suffix, custom_callable, with_prov,
if outtype == 'dicom':
convert_dicom(item_dicoms, bids_options, prefix,
outdir, tempdirs, symlink, overwrite)
elif outtype == 'physio':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would need to document that, e.g. at https://github.com/nipy/heudiconv/blob/HEAD/docs/heuristics.rst#infotodictseqinfos (make it all into a nice itemized list there for nii, dicom and now physio)

"bidsphysio.dcm2bids not found. "
"Not extracting physiological recordings."
)
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be ok with erroring out here since if heuristic did instruct to get those physio - we better have all dependencies

'datalad': ['datalad >=%s' % MIN_DATALAD_VERSION]
'datalad': ['datalad >=%s' % MIN_DATALAD_VERSION],
'physio': [
'bidsphysio.dcm2bids >=1.4.3; python_version>"3.5"', # if dicoms with physio need to be converted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'bidsphysio.dcm2bids >=1.4.3; python_version>"3.5"', # if dicoms with physio need to be converted
'bidsphysio.dcm2bids >=1.4.3', # if dicoms with physio need to be converted

as 3.5 is already below what we support

'datalad': ['datalad >=%s' % MIN_DATALAD_VERSION],
'physio': [
'bidsphysio.dcm2bids >=1.4.3; python_version>"3.5"', # if dicoms with physio need to be converted
]
}

# Flatten the lists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all those binary files below adding up to over 1MB -- I think should be moved to some external dataset and used via fetch_data. ATM fetch_data hardcodes to access from datasets.datalad.org but I think we should change that -- if full url is provided - just use that URL, and then share them on some repo, could be even not annex, just regular git repo on github.

Later we should improve this fetch_data to make data persistent locally etc... but not for this PR.

@@ -46,7 +46,8 @@
'patient_sex', # 23
'date', # 24
'series_uid', # 25
]
'time', # 26
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would conflict with WiP of #637 / #581 but the main concern is that I do not see it needed/used at all by the target need of this PR -- conversion of physio data. Spurious wishful change? ;-)

@yarikoptic yarikoptic marked this pull request as draft February 17, 2023 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants