-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #551 from rordenlab/development
New stable release ( v1.0.20211006)
- Loading branch information
Showing
40 changed files
with
14,068 additions
and
12,600 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env python | ||
"""extract_units.py - extract BIDS/README.md's units as json | ||
Usage: | ||
extract_units.py [-e EXISTING -o OUT] [MD] | ||
extract_units.py (-h|--help|--version) | ||
Arguments: | ||
MD: A Markdown input file including tables with Field and Unit as the | ||
first two columns. | ||
[default: README.md] | ||
Options: | ||
-h --help Show this message and exit. | ||
--version Show version and exit. | ||
-e EXISTING --ex=EXISTING Extract units for all the fields, and only the | ||
fields in EXISTING, a BIDS file, and write the | ||
output to | ||
EXISTING.replace('.json', '_units.json') | ||
instead of stdout. | ||
-o OUT --out=OUT If given, save the output to this filename. | ||
(Overrides the implicit destination of -e.) | ||
""" | ||
from __future__ import print_function | ||
try: | ||
import json_tricks as json | ||
except ImportError: | ||
try: | ||
import simplejson as json | ||
except ImportError: | ||
# Not really compatible with json_tricks because it does not support | ||
# primitives=True | ||
import json | ||
import sys | ||
|
||
# Please use semantic versioning (API.feature.bugfix), http://semver.org/ | ||
__version__ = '0.0.0' | ||
|
||
|
||
def extract_units(mdfn): | ||
units = {} | ||
intable = False | ||
with open(mdfn) as md: | ||
for line in md: | ||
if line.startswith('|'): | ||
parts = [s.strip() for s in line.split('|')[1:-1]] | ||
if parts[:2] == ['Field', 'Unit']: | ||
intable = True | ||
elif intable and parts[1] and not parts[1].startswith('-'): | ||
units[parts[0]] = parts[1] | ||
else: | ||
intable = False | ||
return units | ||
|
||
|
||
def main(mdfn, existing=None, outfn=None): | ||
units = extract_units(mdfn) | ||
if existing: | ||
with open(existing) as f: # Can't count on having json_tricks. | ||
used = json.load(f) | ||
units = {k: v for k, v in units.items() if k in used} | ||
if not outfn: | ||
outfn = existing.replace('.json', '_units.json') | ||
outtext = json.dumps(units, indent=2, sort_keys=True, | ||
separators=(', ', ': ')) | ||
if outfn: | ||
with open(outfn, 'w') as outf: | ||
outf.write(outtext + "\n") | ||
else: | ||
print(outtext) | ||
return units | ||
|
||
|
||
if __name__ == '__main__': | ||
from docopt import docopt | ||
|
||
args = docopt(__doc__, version=__version__) | ||
|
||
# https://github.com/docopt/docopt/issues/214 has been open for | ||
# almost 7 years, so it looks like docopt isn't getting default | ||
# positional args. | ||
output = main(args['MD'] or 'README.md', | ||
args.get('--ex'), args.get('--out')) | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#### Introduction | ||
|
||
dcm2niix is a community effort | ||
|
||
Like the [Brain Imaging Data Structure](https://bids.neuroimaging.io/get_involved.html), which it supports, dcm2niix is developed by the community for the community and everybody can become a part of the community. | ||
|
||
The easiest way to contribute to dcm2niix is to ask questions you have by [generating Github issues](https://github.com/rordenlab/dcm2niix/issues) or [asking a question on the NITRC forum](https://www.nitrc.org/forum/?group_id=880). | ||
|
||
The code is open source, and you can share your improvements by [creating a pull request](https://github.com/rordenlab/dcm2niix/pulls). | ||
dcm2niix is a community project that has benefitted from many [contrbutors](https://github.com/rordenlab/dcm2niix/graphs/contributors). | ||
|
||
The INCF suggests indicating who is responsible for maintaining software for [stability and support](https://incf.org/incf-standards-review-criteria-v20). Therefore, below we indicate several active contributors and their primary domain of expertise. However, this list is not comprehensive, and it is noted that the project has been supported by contributions from many users. This list does not reflect magnitude of prior contributions, rather it is a non-exhaustive list of members who are actively maintaining the project. | ||
|
||
- Jon Clayden: (@jonclayden): [R Deployment](https://github.com/jonclayden/divest) | ||
- Ningfei Li : (@ningfei) CMake, AppVeyor, Travis | ||
- Yaroslav O. Halchenko: (@yarikoptic) Debian distributions | ||
- Taylor Hanayik (@hanayik): FSL integration | ||
- Michael Harms (@mharms): Advanced modalities | ||
- Roger D Newman-Norlund (@rogiedodgie): User support | ||
- Rob Reid (@captainnova): Clinical modalities | ||
- Chris Rorden (@neurolabusc): General development, user support | ||
|
||
#### Style Guide | ||
|
||
dcm2niix is written in C. Different programmers prefer different styles of indentation. Feel free to contribute code without being concerned about matching the style of the rest of the code. Once in a while, the code base will be automatically reformatted to make it appear more consistent for all users. This is done automatically with clang-format: | ||
|
||
``` | ||
clang-format -i -style="{BasedOnStyle: LLVM, IndentWidth: 4, IndentCaseLabels: false, TabWidth: 4, UseTab: Always, ColumnLimit: 0}" *.cpp *.h | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## About | ||
|
||
dcm2niix attempts to convert all DICOM images to NIfTI. However, different manufacturers handle the format differently. [Mediso](https://mediso.com/usa/en/) is a manufacturer that supports preclinical tools for PET, MRI, SPECT and CT. | ||
|
||
In general, this manufacturer uses public tags and generates simple DICOM headers. While these files do not contain the rich meta data available from other manufacturers, they are simple to parse. | ||
|
||
## Sample Datasets | ||
|
||
- The [ftp://medical.nema.org/MEDICAL](ftp://medical.nema.org/MEDICAL) server provides reference images in Dicom/Datasets/WG30/Mediso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.