Skip to content

Commit

Permalink
Merge pull request raamana#7 from sinhaharsh/master
Browse files Browse the repository at this point in the history
Modify __str__ for BaseSequence
  • Loading branch information
raamana committed Feb 26, 2024
2 parents 6a8f367 + 925dac0 commit 36449f7
Show file tree
Hide file tree
Showing 20 changed files with 333 additions and 165 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
pip install .
pip install .[test]
- name: Lint with flake8
run: |
make lint
- name: Test with pytest
working-directory: ${{ runner.temp }}
run: |
pytest
pytest --pyargs protocol
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

19 changes: 17 additions & 2 deletions protocol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

__author__ = """Pradeep Reddy Raamana"""
__email__ = '[email protected]'
__version__ = '0.1.0'
# __version__ = '0.1.0'

import logging
import sys

from protocol.config import configure_logger

Expand All @@ -19,4 +20,18 @@
BASE_IMAGING_PARAMS_DICOM_TAGS,
ACRONYMS_IMAGING_PARAMETERS,
UnspecifiedType)
from protocol.imaging import DicomImagingSequence, BidsImagingSequence, SiemensMRImagingProtocol, MRImagingProtocol
from protocol.imaging import (DicomImagingSequence, BidsImagingSequence,
SiemensMRImagingProtocol, MRImagingProtocol)

try:
from protocol._version import __version__
except ImportError:
if sys.version_info < (3, 8):
from importlib_metadata import version
else:
from importlib.metadata import version

try:
__version__ = version('protocol')
except Exception:
__version__ = "unknown"
3 changes: 2 additions & 1 deletion protocol/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ def __str__(self):
for key in self.params:
param = self.__dict__[key]
name = param.acronym if param.acronym else param.name
plist.append(f'{name}={param._value}')
if not isinstance(param.get_value(), UnspecifiedType):
plist.append(f'{name}={param.get_value()}')

return '{}({})'.format(self.name, ','.join(plist))

Expand Down
39 changes: 35 additions & 4 deletions protocol/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path


def configure_logger(log, output_dir, mode='w', level='WARNING'):
def configure_logger(log, output_dir, mode='w', level='ERROR'):
"""
Initiate log files.
Expand All @@ -29,7 +29,7 @@ def configure_logger(log, output_dir, mode='w', level='WARNING'):
error_formatter = '%(asctime)s - %(levelname)s - %(message)s'
if output_dir is None:
output_dir = tempfile.gettempdir()
output_dir = Path(output_dir) / '.mrdataset'
output_dir = Path(output_dir) / '.protocol'
output_dir.mkdir(parents=True, exist_ok=True)

options = {
Expand Down Expand Up @@ -161,6 +161,7 @@ def __repr__(self):
'PartialFourier' : (0x18, 0x9081),
'PartialFourierDirection' : (0x18, 0x9036),
'PhaseEncodingDirection' : (0x18, 0x1312),
'InPlanePhaseEncodingDirection' : (0x18, 0x1312),

# Timing Parameters
'EchoTime' : (0x18, 0x81),
Expand All @@ -172,7 +173,7 @@ def __repr__(self):
'FlipAngle' : (0x18, 0x1314),

# Slice Acceleration Parameters
'MultiBandAccelerationFactor' : (0x43, 0x1083),
'MultibandAccelerationFactor' : (0x43, 0x1083),

# Misc Parameters
'BodyPartExamined' : (0x18, 0x15),
Expand Down Expand Up @@ -254,7 +255,7 @@ def __repr__(self):
'DwellTime' : 'DT',
'RepetitionTime' : 'TR',
'FlipAngle' : 'FA',
'MultiBandAccelerationFactor' : 'MAF',
'MultibandAccelerationFactor' : 'MAF',
'BodyPartExamined' : 'BPE',
'EchoTrainLength' : 'ETL',
'PixelBandwidth' : 'PBW',
Expand Down Expand Up @@ -303,6 +304,8 @@ def __repr__(self):
'PositivePCSDirections' : 'PPCSD',
'FieldOfView' : 'FOV',
'ImageType' : 'IT',
'InPlanePhaseEncodingDirection' : 'PPED',
'EffectiveEchoSpacing' : 'EES',
}

ACRONYMS_DEMOGRAPHICS = {
Expand All @@ -317,6 +320,34 @@ def __repr__(self):
"ContentTime" : "CT",
}

PARAMETERS_ANALOGUES = {
'InPlanePhaseEncodingDirection': [
'InPlanePhaseEncodingDirectionDICOM',
],
'ManufacturersModelName': [
'ManufacturerModelName',
],
'PhaseEncodingSteps' : [
'NumberOfPhaseEncodingSteps',
],
'PercentPhaseFOV' : [
'PercentPhaseFieldOfView',
],

}

INVALID_PARAMETERS = [
'DatasetType', 'License', 'Authors', 'Acknowledgements',
'HowToAcknowledge', 'Funding', 'ReferencesAndLinks',
'DatasetDOI', 'EthicsApprovals', 'ClinicalTrials',
'Name', 'Description', 'BIDSVersion',
]

# Invert the dictionary to get the reverse mapping
PARAMETERS_ANALOGUES_DICT = {val: key
for key, values in PARAMETERS_ANALOGUES.items()
for val in values}

BASE_IMAGING_PARAMETER_NAMES = list(BASE_IMAGING_PARAMS_DICOM_TAGS.keys())

# Constant dicom Identifiers used to extract dicom headers
Expand Down
Loading

0 comments on commit 36449f7

Please sign in to comment.