├── .gitignore ├── bidsphysio ├── __init__.py └── info.py ├── requirements.txt ├── bidsphysio.base ├── tests │ ├── __init__.py │ ├── data │ │ ├── test_nan_TR_physio.tsv.gz │ │ └── test_nan_TR_physio.json │ ├── utils.py │ └── test_utils.py ├── bidsphysio │ ├── __init__.py │ └── base │ │ ├── __init__.py │ │ ├── info.py │ │ └── utils.py ├── setup.py └── README.md ├── .dockerignore ├── bidsphysio.acq2bids ├── tests │ ├── __init__.py │ ├── utils.py │ ├── data │ │ ├── sample.acq │ │ └── acq_physio.json │ ├── test_acqsession2bids.py │ └── test_acq2bidsphysio.py ├── bidsphysio │ ├── __init__.py │ └── acq2bids │ │ ├── __init__.py │ │ ├── info.py │ │ ├── acqsession2bids.py │ │ └── acq2bidsphysio.py ├── setup.py └── README.md ├── bidsphysio.dcm2bids ├── tests │ ├── __init__.py │ ├── data │ │ ├── samplePhysioCMRR.dcm │ │ ├── samplePhysioCMRR_ecg.dcm │ │ ├── dcm_cardiac.json │ │ ├── dcm_respiratory.json │ │ ├── dcm_external_trigger.json │ │ ├── Physio_PULS.log │ │ ├── Physio_RESP.log │ │ ├── dcm_external_trigger.tsv │ │ ├── Physio_Info.log │ │ └── dcm_respiratory.tsv │ ├── utils.py │ ├── test_dcmsession2bids.py │ └── test_dcm2bidsphysio.py ├── bidsphysio │ ├── __init__.py │ └── dcm2bids │ │ ├── __init__.py │ │ ├── info.py │ │ └── dcmsession2bids.py ├── setup.py └── README.md ├── bidsphysio.events ├── tests │ ├── __init__.py │ ├── utils.py │ └── test_eventsbase.py ├── bidsphysio │ ├── __init__.py │ └── events │ │ ├── __init__.py │ │ ├── info.py │ │ └── eventsbase.py ├── setup.py └── README.md ├── bidsphysio.pmu2bids ├── tests │ ├── __init__.py │ ├── data │ │ ├── pmu_VBX_cardiac.tsv │ │ ├── sample.acq │ │ ├── pmu_VE11C_cardiac.json │ │ ├── pmu_VE11C_respiratory.json │ │ ├── sample_VBX.puls │ │ ├── pmu_VE11C_respiratory.tsv │ │ ├── pmu_VB15A_respiratory.tsv │ │ └── pmu_VE11C_cardiac.tsv │ └── utils.py ├── bidsphysio │ ├── __init__.py │ └── pmu2bids │ │ ├── __init__.py │ │ └── info.py ├── setup.py └── README.md ├── bidsphysio.session ├── tests │ ├── __init__.py │ ├── data │ ├── utils.py │ └── test_session2bids.py ├── bidsphysio │ ├── __init__.py │ └── session │ │ ├── __init__.py │ │ └── info.py ├── setup.py └── README.md ├── bidsphysio.physio2bids ├── tests │ ├── __init__.py │ ├── data │ │ ├── pmu_VBX_cardiac.tsv │ │ ├── sample.acq │ │ ├── samplePhysioCMRR.dcm │ │ ├── sample_VBX.puls │ │ ├── pmu_VE11C_respiratory.tsv │ │ ├── pmu_VE11C_cardiac.tsv │ │ ├── pmu_VB15A_respiratory.tsv │ │ ├── dcm_respiratory.tsv │ │ ├── dcm_cardiac.tsv │ │ └── acq_physio.tsv │ ├── utils.py │ └── test_physio2bidsphysio.py ├── bidsphysio │ ├── __init__.py │ └── physio2bids │ │ ├── __init__.py │ │ ├── info.py │ │ └── physio2bidsphysio.py ├── README.md └── setup.py ├── bidsphysio.edf2bids ├── tests │ ├── __init__.py │ ├── utils.py │ ├── data │ │ ├── sample.edf │ │ ├── testeye_recording-eyetracking_physio.json │ │ └── testeye_events.tsv │ ├── __pycache__ │ │ └── utils.cpython-37.pyc │ ├── test_edfsession2bids.py │ └── test_edf2bidsphysio.py ├── bidsphysio │ ├── __init__.py │ └── edf2bids │ │ ├── __init__.py │ │ ├── info.py │ │ └── edfsession2bids.py ├── setup.py └── README.md ├── .coveragerc ├── dev-requirements.txt ├── .codecov.yml ├── .zenodo.json ├── LICENSE ├── .travis.yml ├── setup.py ├── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | .[all] 2 | -------------------------------------------------------------------------------- /bidsphysio.base/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | .git/ 3 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bidsphysio.events/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bidsphysio.session/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bidsphysio.session/tests/data: -------------------------------------------------------------------------------- 1 | ../../bidsphysio.acq2bids/tests/data -------------------------------------------------------------------------------- /bidsphysio.base/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/tests/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.base/bidsphysio/base/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.events/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.session/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.events/bidsphysio/events/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/bidsphysio/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/bidsphysio/acq2bids/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/bidsphysio/dcm2bids/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/bidsphysio/edf2bids/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/bidsphysio/pmu2bids/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.session/bidsphysio/session/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/bidsphysio/physio2bids/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/tests/utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 4 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/tests/utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 4 | -------------------------------------------------------------------------------- /bidsphysio.events/tests/utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 4 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/pmu_VBX_cardiac.tsv: -------------------------------------------------------------------------------- 1 | 1653.0000 2 | 1593.0000 3 | 1545.0000 4 | 1510.0000 5 | 1484.0000 6 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/pmu_VBX_cardiac.tsv: -------------------------------------------------------------------------------- 1 | 1653.0000 2 | 1593.0000 3 | 1545.0000 4 | 1510.0000 5 | 1484.0000 6 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 4 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 4 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | 3 | [report] 4 | omit = */info.py 5 | */setup.py 6 | exclude_lines = if __name__ == '__main__': 7 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | -r requirements.txt 2 | # Fix version of pytest to ease backward compatibility testing 3 | pytest==5.4.3 4 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/tests/data/sample.acq: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.acq2bids/tests/data/sample.acq -------------------------------------------------------------------------------- /bidsphysio.edf2bids/tests/data/sample.edf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.edf2bids/tests/data/sample.edf -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/sample.acq: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.pmu2bids/tests/data/sample.acq -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/sample.acq: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.physio2bids/tests/data/sample.acq -------------------------------------------------------------------------------- /bidsphysio.base/tests/data/test_nan_TR_physio.tsv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.base/tests/data/test_nan_TR_physio.tsv.gz -------------------------------------------------------------------------------- /bidsphysio.base/tests/utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 4 | 5 | EXPECTED_TR = 2.0 # in sec 6 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/data/samplePhysioCMRR.dcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.dcm2bids/tests/data/samplePhysioCMRR.dcm -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/data/samplePhysioCMRR_ecg.dcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.dcm2bids/tests/data/samplePhysioCMRR_ecg.dcm -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/samplePhysioCMRR.dcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.physio2bids/tests/data/samplePhysioCMRR.dcm -------------------------------------------------------------------------------- /bidsphysio.edf2bids/tests/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbinyu/bidsphysio/HEAD/bidsphysio.edf2bids/tests/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/pmu_VE11C_cardiac.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "cardiac" 4 | ], 5 | "SamplingFrequency": 400, 6 | "StartTime": 39008572.0 7 | } 8 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/pmu_VE11C_respiratory.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "respiratory" 4 | ], 5 | "SamplingFrequency": 400, 6 | "StartTime": 38973660.0 7 | } 8 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/data/dcm_cardiac.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "cardiac", 4 | "trigger" 5 | ], 6 | "SamplingFrequency": 200.0, 7 | "StartTime": -12.082 8 | } 9 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/data/dcm_respiratory.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "respiratory", 4 | "trigger" 5 | ], 6 | "SamplingFrequency": 50.0, 7 | "StartTime": -12.082 8 | } 9 | -------------------------------------------------------------------------------- /bidsphysio.base/tests/data/test_nan_TR_physio.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "external_trigger", 4 | "trigger" 5 | ], 6 | "SamplingFrequency": 50.0, 7 | "StartTime": -0.024 8 | } 9 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/data/dcm_external_trigger.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "external_trigger", 4 | "trigger" 5 | ], 6 | "SamplingFrequency": 50.0, 7 | "StartTime": -0.024 8 | } 9 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/utils.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 4 | 5 | # These are the last 6 digits in the second line in the ".log" files: 6 | EXPECTED_ACQ_TIME = 143828 7 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | # Travis-CI writes the paths in the coverage reports as: 2 | # codecov.io/gh/cbinyu/bidsphysio/src//... 3 | # However, the path in GitHub is: 4 | # github.com/cbinyu/bidsphysio/blob//... 5 | 6 | fixes: 7 | - "src/::blob/" # move path -------------------------------------------------------------------------------- /bidsphysio.session/tests/utils.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | from pathlib import Path 3 | 4 | TESTS_DATA_PATH = Path(__file__).parent / 'data' 5 | 6 | 7 | def file_md5sum(filename): 8 | with open(filename, 'rb') as f: 9 | return hashlib.md5(f.read()).hexdigest() 10 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/tests/data/testeye_recording-eyetracking_physio.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "samples", 4 | "gx_left", 5 | "gy_left", 6 | "pa_left", 7 | "trigger", 8 | "fixation", 9 | "saccade", 10 | "blink" 11 | ], 12 | "RecordedEye": "Left", 13 | "SamplingFrequency": 500, 14 | "StartTime": -21.256 15 | } 16 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/tests/data/acq_physio.json: -------------------------------------------------------------------------------- 1 | { 2 | "Columns": [ 3 | "cardiac", 4 | "respiratory", 5 | "GSR", 6 | "trigger" 7 | ], 8 | "GSR": { 9 | "Units": "microsiemens" 10 | }, 11 | "SamplingFrequency": 500.0, 12 | "StartTime": -0.6, 13 | "cardiac": { 14 | "Units": "Volts" 15 | }, 16 | "respiratory": { 17 | "Units": "Volts" 18 | }, 19 | "trigger": { 20 | "Units": "Volts" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/sample_VBX.puls: -------------------------------------------------------------------------------- 1 | 1 2 40 280 5002 Logging PULSE signal: reduction factor = 1, PULS_SAMPLES_PER_SECOND = 50; PULS_SAMPLE_INTERVAL = 20000 6002 1653 1593 1545 1510 1484 2 | ACQ FINISHED 3 | 6002 3093 3096 3064 5000 3016 2926 5003 4 | ECG Freq Per: 0 0 5 | PULS Freq Per: 66 906 6 | RESP Freq Per: 18 3260 7 | EXT Freq Per: 0 0 8 | ECG Min Max Avg StdDiff: 0 0 0 0 9 | PULS Min Max Avg StdDiff: 731 1113 914 1 10 | RESP Min Max Avg StdDiff: 3080 4540 3779 73 11 | EXT Min Max Avg StdDiff: 0 0 0 0 12 | NrTrig NrMP NrArr AcqWin: 0 0 0 0 13 | LogStartMDHTime: 47029710 14 | LogStopMDHTime: 47654452 15 | LogStartMPCUTime: 47030087 16 | LogStopMPCUTime: 47652240 17 | 6003 18 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/sample_VBX.puls: -------------------------------------------------------------------------------- 1 | 1 2 40 280 5002 Logging PULSE signal: reduction factor = 1, PULS_SAMPLES_PER_SECOND = 50; PULS_SAMPLE_INTERVAL = 20000 6002 1653 1593 1545 1510 1484 2 | ACQ FINISHED 3 | 6002 3093 3096 3064 5000 3016 2926 5003 4 | ECG Freq Per: 0 0 5 | PULS Freq Per: 66 906 6 | RESP Freq Per: 18 3260 7 | EXT Freq Per: 0 0 8 | ECG Min Max Avg StdDiff: 0 0 0 0 9 | PULS Min Max Avg StdDiff: 731 1113 914 1 10 | RESP Min Max Avg StdDiff: 3080 4540 3779 73 11 | EXT Min Max Avg StdDiff: 0 0 0 0 12 | NrTrig NrMP NrArr AcqWin: 0 0 0 0 13 | LogStartMDHTime: 47029710 14 | LogStopMDHTime: 47654452 15 | LogStartMPCUTime: 47030087 16 | LogStopMPCUTime: 47652240 17 | 6003 18 | -------------------------------------------------------------------------------- /.zenodo.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "bidsphysio: Converts physio data to BIDS physiological recording", 3 | "description": "

bidsphysio is a package that converts physiological data (CMRR, AcqKnowledge, Siemens PMU) to BIDS physiological recording.

", 4 | "contributors": [ 5 | ], 6 | "creators": [ 7 | { 8 | "affiliation": "Center for Brain Imaging, New York University", 9 | "name": "Velasco, Pablo", 10 | "orcid": "0000-0002-5749-6049" 11 | } 12 | ], 13 | "keywords": [ 14 | "neuroimaging", 15 | "physiology", 16 | "PMU", 17 | "AcqKnowledge", 18 | "fMRI", 19 | "BIDS" 20 | ], 21 | "license": "MIT", 22 | "related_identifiers": [ 23 | ], 24 | "upload_type": "software" 25 | } 26 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/README.md: -------------------------------------------------------------------------------- 1 | # bidsphysio.physio2bids 2 | Converts physio data (CMRR, AcqKnowledge, Siemens PMU) to BIDS physiological recording 3 | 4 | [![Docker image](https://img.shields.io/badge/docker-cbinyu/bidsphysio:latest-brightgreen.svg?logo=docker&style=flat)](https://hub.docker.com/r/cbinyu/bidsphysio/tags/) 5 | [![TravisCI](https://travis-ci.com/cbinyu/bidsphysio.svg?branch=master)](https://travis-ci.com/cbinyu/bidsphysio) 6 | [![CodeCoverage](https://codecov.io/gh/cbinyu/bidsphysio/branch/master/graph/badge.svg)](https://codecov.io/gh/cbinyu/bidsphysio) 7 | [![DOI](https://zenodo.org/badge/239006399.svg)](https://zenodo.org/badge/latestdoi/239006399) 8 | 9 | This sub-class is a wrapper that will take the input file extension and run the converter corresponding to that file type. 10 | 11 | For usage and installation, check the [README.md](../README.md) file for the project. -------------------------------------------------------------------------------- /bidsphysio.base/bidsphysio/base/info.py: -------------------------------------------------------------------------------- 1 | __version__ ="21.06.24" 2 | __author__ = "Pablo Velasco, Chrysa Papadaniil" 3 | __author_email__ = "pablo.velasco@nyu.edu" 4 | __url__ = "https://github.com/cbinyu/bidsphysio" 5 | __packagename__ = 'bidsphysio.base' 6 | __description__ = "BIDS Physiology classes" 7 | __license__ = "MIT" 8 | __longdesc__ = """Base classes to handle BIDS physiology signals.""" 9 | 10 | CLASSIFIERS = [ 11 | 'Environment :: Console', 12 | 'Intended Audience :: Science/Research', 13 | 'License :: OSI Approved :: MIT License', 14 | 'Programming Language :: Python :: 3.6', 15 | 'Programming Language :: Python :: 3.7', 16 | 'Programming Language :: Python :: 3.8', 17 | 'Topic :: Scientific/Engineering' 18 | ] 19 | 20 | PYTHON_REQUIRES = ">=3.6" 21 | 22 | REQUIRES = [ 23 | 'numpy >= 1.17.1', 24 | ] 25 | 26 | TESTS_REQUIRES = [ 27 | 'pytest' 28 | ] 29 | 30 | EXTRA_REQUIRES = { 31 | 'tests': TESTS_REQUIRES, 32 | } 33 | 34 | # Flatten the lists 35 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 36 | -------------------------------------------------------------------------------- /bidsphysio.events/bidsphysio/events/info.py: -------------------------------------------------------------------------------- 1 | __version__ ="21.06.24" 2 | __author__ = "Chrysa Papadaniil, Pablo Velasco" 3 | __author_email__ = "chrysa@nyu.edu" 4 | __url__ = "https://github.com/cbinyu/bidsphysio" 5 | __packagename__ = 'bidsphysio.events' 6 | __description__ = "BIDS Events classes" 7 | __license__ = "MIT" 8 | __longdesc__ = """Base classes to handle BIDS event data.""" 9 | 10 | CLASSIFIERS = [ 11 | 'Environment :: Console', 12 | 'Intended Audience :: Science/Research', 13 | 'License :: OSI Approved :: MIT License', 14 | 'Programming Language :: Python :: 3.6', 15 | 'Programming Language :: Python :: 3.7', 16 | 'Programming Language :: Python :: 3.8', 17 | 'Topic :: Scientific/Engineering' 18 | ] 19 | 20 | PYTHON_REQUIRES = ">=3.6" 21 | 22 | REQUIRES = [ 23 | 'numpy >= 1.20.1', 24 | 'pandas>=1.1.0', 25 | ] 26 | 27 | TESTS_REQUIRES = [ 28 | 'pytest' 29 | ] 30 | 31 | EXTRA_REQUIRES = { 32 | 'tests': TESTS_REQUIRES, 33 | } 34 | 35 | # Flatten the lists 36 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 NYU's Center for Brain Imaging 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | - "3.7" 5 | - "3.8" 6 | 7 | cache: 8 | - apt 9 | 10 | before_install: 11 | - python -m pip install --upgrade pip 12 | - pip install codecov pytest pytest-cov 13 | - sudo apt-get update 14 | - sudo apt-get -y install libxml2-dev 15 | - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 16 | - sudo apt-get -q update 17 | - sudo apt-get -y install gcc-4.8 18 | - sudo apt-get install gnupg2 19 | - curl -L "https://download.sr-support.com/SRResearch_key" | sudo apt-key add - 20 | - sudo add-apt-repository "deb [arch=amd64] http://download.sr-support.com/software SRResearch main" 21 | - sudo apt-get update 22 | - sudo apt-get install -y eyelink-edfapi 23 | - export C_INCLUDE_PATH="/usr/include/EyeLink:$C_INCLUDE_PATH" 24 | 25 | install: 26 | - pip install pandas 27 | - pip install Cython 28 | - pip install h5py 29 | - git clone https://github.com/nwilming/pyedfread.git 30 | - cd pyedfread && python setup.py install && cd .. 31 | - pip install -r dev-requirements.txt 32 | 33 | # command to run tests 34 | script: 35 | - for d in bidsphysio.*; do pytest --cov=$d --cov-append $d; done 36 | 37 | after_success: 38 | - codecov 39 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/bidsphysio/pmu2bids/info.py: -------------------------------------------------------------------------------- 1 | """ NOTE: When bumping up the version number, double-check if you 2 | need to also bump up the version of the dependencies 3 | """ 4 | 5 | __version__ ="21.06.24" 6 | __author__ = "Pablo Velasco" 7 | __author_email__ = "pablo.velasco@nyu.edu" 8 | __url__ = "https://github.com/cbinyu/bidsphysio" 9 | __packagename__ = 'bidsphysio.pmu2bids' 10 | __description__ = "Siemens-PMU-to-BIDS Converter" 11 | __license__ = "MIT" 12 | __longdesc__ = """Converts physio data from a Siemens PMU file to BIDS physiological recording.""" 13 | 14 | CLASSIFIERS = [ 15 | 'Environment :: Console', 16 | 'Intended Audience :: Science/Research', 17 | 'License :: OSI Approved :: MIT License', 18 | 'Programming Language :: Python :: 3.6', 19 | 'Programming Language :: Python :: 3.7', 20 | 'Programming Language :: Python :: 3.8', 21 | 'Topic :: Scientific/Engineering' 22 | ] 23 | 24 | PYTHON_REQUIRES = ">=3.6" 25 | 26 | REQUIRES = [ 27 | 'bidsphysio.base >= 1.3.1', 28 | ] 29 | 30 | TESTS_REQUIRES = [ 31 | 'pytest' 32 | ] 33 | 34 | EXTRA_REQUIRES = { 35 | 'tests': TESTS_REQUIRES, 36 | } 37 | 38 | # Flatten the lists 39 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 40 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/bidsphysio/physio2bids/info.py: -------------------------------------------------------------------------------- 1 | """ NOTE: When bumping up the version number, double-check if you 2 | need to also bump up the version of the dependencies 3 | """ 4 | 5 | __version__ ="21.06.24" 6 | __author__ = "Pablo Velasco" 7 | __author_email__ = "pablo.velasco@nyu.edu" 8 | __url__ = "https://github.com/cbinyu/bidsphysio" 9 | __packagename__ = 'bidsphysio.physio2bids' 10 | __description__ = "Physiology-to-BIDS Converter" 11 | __license__ = "MIT" 12 | __longdesc__ = """Converts physio data from a few different files to BIDS physiological recording.""" 13 | 14 | CLASSIFIERS = [ 15 | 'Environment :: Console', 16 | 'Intended Audience :: Science/Research', 17 | 'License :: OSI Approved :: MIT License', 18 | 'Programming Language :: Python :: 3.6', 19 | 'Programming Language :: Python :: 3.7', 20 | 'Programming Language :: Python :: 3.8', 21 | 'Topic :: Scientific/Engineering' 22 | ] 23 | 24 | PYTHON_REQUIRES = ">=3.6" 25 | 26 | REQUIRES = [ 27 | 'bidsphysio >= 4.3.3', 28 | ] 29 | 30 | TESTS_REQUIRES = [ 31 | 'pytest' 32 | ] 33 | 34 | EXTRA_REQUIRES = { 35 | 'tests': TESTS_REQUIRES, 36 | } 37 | 38 | # Flatten the lists 39 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 40 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/bidsphysio/acq2bids/info.py: -------------------------------------------------------------------------------- 1 | """ NOTE: When bumping up the version number, double-check if you 2 | need to also bump up the version of the dependencies 3 | """ 4 | 5 | __version__ ="21.06.24" 6 | __author__ = "Pablo Velasco" 7 | __author_email__ = "pablo.velasco@nyu.edu" 8 | __url__ = "https://github.com/cbinyu/bidsphysio" 9 | __packagename__ = 'bidsphysio.acq2bids' 10 | __description__ = "AcqKnowledge-to-BIDS Converter" 11 | __license__ = "MIT" 12 | __longdesc__ = """Converts physio data from an AcqKnowledge file to BIDS physiological recording.""" 13 | 14 | CLASSIFIERS = [ 15 | 'Environment :: Console', 16 | 'Intended Audience :: Science/Research', 17 | 'License :: OSI Approved :: MIT License', 18 | 'Programming Language :: Python :: 3.6', 19 | 'Programming Language :: Python :: 3.7', 20 | 'Programming Language :: Python :: 3.8', 21 | 'Topic :: Scientific/Engineering' 22 | ] 23 | 24 | PYTHON_REQUIRES = ">=3.6" 25 | 26 | REQUIRES = [ 27 | 'bidsphysio.base>=21.5.27', 28 | 'bidsphysio.session>=21.06.24', 29 | 'bioread[mat]>=2.0.0', 30 | ] 31 | 32 | TESTS_REQUIRES = [ 33 | 'pytest' 34 | ] 35 | 36 | EXTRA_REQUIRES = { 37 | 'tests': TESTS_REQUIRES, 38 | } 39 | 40 | # Flatten the lists 41 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 42 | -------------------------------------------------------------------------------- /bidsphysio.session/bidsphysio/session/info.py: -------------------------------------------------------------------------------- 1 | """ NOTE: When bumping up the version number, double-check if you 2 | need to also bump up the version of the dependencies 3 | """ 4 | 5 | __version__ = "21.06.24" 6 | __author__ = "Pablo Velasco, Chrysa Papadaniil" 7 | __author_email__ = "pablo.velasco@nyu.edu" 8 | __url__ = "https://github.com/cbinyu/bidsphysio" 9 | __packagename__ = 'bidsphysio.session' 10 | __description__ = "physio-session-to-BIDS Converter" 11 | __license__ = "MIT" 12 | __longdesc__ = """Automatically converts a whole session worth of physio data to BIDS physiological recording.""" 13 | 14 | CLASSIFIERS = [ 15 | 'Environment :: Console', 16 | 'Intended Audience :: Science/Research', 17 | 'License :: OSI Approved :: MIT License', 18 | 'Programming Language :: Python :: 3.6', 19 | 'Programming Language :: Python :: 3.7', 20 | 'Programming Language :: Python :: 3.8', 21 | 'Topic :: Scientific/Engineering' 22 | ] 23 | 24 | PYTHON_REQUIRES = ">=3.6" 25 | 26 | REQUIRES = [ 27 | 'bidsphysio.base>=1.4.0', 28 | 'bids', 29 | 'pandas', 30 | 'numpy >= 1.17.1', 31 | 'matplotlib', 32 | ] 33 | 34 | TESTS_REQUIRES = [ 35 | 'pytest' 36 | ] 37 | 38 | EXTRA_REQUIRES = { 39 | 'tests': TESTS_REQUIRES, 40 | } 41 | 42 | # Flatten the lists 43 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 44 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/bidsphysio/dcm2bids/info.py: -------------------------------------------------------------------------------- 1 | """ NOTE: When bumping up the version number, double-check if you 2 | need to also bump up the version of the dependencies 3 | """ 4 | 5 | __version__ = "21.06.24" 6 | __author__ = "Pablo Velasco" 7 | __author_email__ = "pablo.velasco@nyu.edu" 8 | __url__ = "https://github.com/cbinyu/bidsphysio" 9 | __packagename__ = 'bidsphysio.dcm2bids' 10 | __description__ = "Physio-DICOM-to-BIDS Converter" 11 | __license__ = "MIT" 12 | __longdesc__ = """Converts physio data from a CMRR physiology DICOM file or log file to BIDS physiological recording.""" 13 | 14 | CLASSIFIERS = [ 15 | 'Environment :: Console', 16 | 'Intended Audience :: Science/Research', 17 | 'License :: OSI Approved :: MIT License', 18 | 'Programming Language :: Python :: 3.6', 19 | 'Programming Language :: Python :: 3.7', 20 | 'Programming Language :: Python :: 3.8', 21 | 'Topic :: Scientific/Engineering' 22 | ] 23 | 24 | PYTHON_REQUIRES = ">=3.6" 25 | 26 | REQUIRES = [ 27 | 'bidsphysio.base >= 1.4.0', 28 | 'bidsphysio.session >= 1.4.0', 29 | 'numpy >= 1.17.1', 30 | 'pydicom >= 1.4.1', 31 | ] 32 | 33 | TESTS_REQUIRES = [ 34 | 'pytest' 35 | ] 36 | 37 | EXTRA_REQUIRES = { 38 | 'tests': TESTS_REQUIRES, 39 | } 40 | 41 | # Flatten the lists 42 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 43 | -------------------------------------------------------------------------------- /bidsphysio.base/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See dcm2bidsphysio.py file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'base', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | python_requires=ldict['PYTHON_REQUIRES'], 36 | install_requires=ldict['REQUIRES'], 37 | extras_require=ldict['EXTRA_REQUIRES'], 38 | ) 39 | 40 | 41 | if __name__ == '__main__': 42 | main() 43 | -------------------------------------------------------------------------------- /bidsphysio.events/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See dcm2bidsphysio.py file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'events', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | python_requires=ldict['PYTHON_REQUIRES'], 36 | install_requires=ldict['REQUIRES'], 37 | extras_require=ldict['EXTRA_REQUIRES'], 38 | ) 39 | 40 | 41 | if __name__ == '__main__': 42 | main() 43 | -------------------------------------------------------------------------------- /bidsphysio.session/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See ../LICENSE file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'session', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | python_requires=ldict['PYTHON_REQUIRES'], 36 | install_requires=ldict['REQUIRES'], 37 | extras_require=ldict['EXTRA_REQUIRES'], 38 | package_data={ 39 | } 40 | ) 41 | 42 | 43 | if __name__ == '__main__': 44 | main() 45 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/bidsphysio/edf2bids/info.py: -------------------------------------------------------------------------------- 1 | """ NOTE: When bumping up the version number, double-check if you 2 | need to also bump up the version of the dependencies 3 | """ 4 | 5 | __version__ ="21.06.24" 6 | __author__ = "Chrysa Papadaniil" 7 | __author_email__ = "chrysa@nyu.edu" 8 | __url__ = "https://github.com/cbinyu/bidsphysio" 9 | __packagename__ = 'bidsphysio.edf2bids' 10 | __description__ = "EDF-to-BIDS Converter" 11 | __license__ = "MIT" 12 | __longdesc__ = """Converts EDF eye-tracker data (from a SR Research Eyelink system) to BIDS eye-tracker physiological recording and events.""" 13 | 14 | CLASSIFIERS = [ 15 | 'Environment :: Console', 16 | 'Intended Audience :: Science/Research', 17 | 'License :: OSI Approved :: MIT License', 18 | 'Programming Language :: Python :: 3.6', 19 | 'Programming Language :: Python :: 3.7', 20 | 'Programming Language :: Python :: 3.8', 21 | 'Topic :: Scientific/Engineering' 22 | ] 23 | 24 | PYTHON_REQUIRES = ">=3.6" 25 | 26 | REQUIRES = [ 27 | 'bidsphysio.base>=21.5.18', 28 | 'bidsphysio.session>=21.5.18', 29 | 'bidsphysio.events>=21.5.27', 30 | 'pyedfread', 31 | 'h5py>=2.9.0', 32 | 'Cython>=0.29.13', 33 | 'pandas>=1.1.0', 34 | 'numpy>= 1.20.1', 35 | ] 36 | 37 | TESTS_REQUIRES = [ 38 | 'pytest' 39 | ] 40 | 41 | EXTRA_REQUIRES = { 42 | 'tests': TESTS_REQUIRES, 43 | } 44 | 45 | # Flatten the lists 46 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 47 | -------------------------------------------------------------------------------- /bidsphysio.events/README.md: -------------------------------------------------------------------------------- 1 | # bidsevents.base 2 | Base classes for BIDS Events 3 | 4 | [![Docker image](https://img.shields.io/badge/docker-cbinyu/bidsphysio:latest-brightgreen.svg?logo=docker&style=flat)](https://hub.docker.com/r/cbinyu/bidsphysio/tags/) 5 | [![TravisCI](https://travis-ci.com/cbinyu/bidsphysio.svg?branch=master)](https://travis-ci.com/cbinyu/bidsphysio) 6 | [![CodeCoverage](https://codecov.io/gh/cbinyu/bidsphysio/branch/master/graph/badge.svg)](https://codecov.io/gh/cbinyu/bidsphysio) 7 | [![DOI](https://zenodo.org/badge/239006399.svg)](https://zenodo.org/badge/latestdoi/239006399) 8 | 9 | ## Installation 10 | You can install the base class from PyPI with `pip`: 11 | 12 | ``` 13 | pip install bidsevents.base 14 | ``` 15 | 16 | Alternatively, you can download the package and install the sub-package with `pip`: 17 | ``` 18 | mkdir /tmp/bidsphysio && \ 19 | curl -sSL https://github.com/cbinyu/bidsphysio/archive/master.tar.gz \ 20 | | tar -vxz -C /tmp/bidsphysio --strip-components=1 && \ 21 | cd /tmp/bidsphysio/bidsevents.base/ && \ 22 | pip install . && \ 23 | cd / && \ 24 | rm -rf /tmp/bidsphysio 25 | ``` 26 | 27 | ## How to use in your own Python program 28 | After installing the module using `pip` (see [above](#installation "Installation") ), you can use it in your own Python program this way: 29 | ``` 30 | from bidsphysio.base.bidsevents import (EventSignal, 31 | EventData) 32 | 33 | mySignal = EventSignal() 34 | ... 35 | ``` 36 | -------------------------------------------------------------------------------- /bidsphysio.base/README.md: -------------------------------------------------------------------------------- 1 | # bidsphysio.base 2 | Base classes for BIDS Physiology 3 | 4 | [![Docker image](https://img.shields.io/badge/docker-cbinyu/bidsphysio:latest-brightgreen.svg?logo=docker&style=flat)](https://hub.docker.com/r/cbinyu/bidsphysio/tags/) 5 | [![TravisCI](https://travis-ci.com/cbinyu/bidsphysio.svg?branch=master)](https://travis-ci.com/cbinyu/bidsphysio) 6 | [![CodeCoverage](https://codecov.io/gh/cbinyu/bidsphysio/branch/master/graph/badge.svg)](https://codecov.io/gh/cbinyu/bidsphysio) 7 | [![DOI](https://zenodo.org/badge/239006399.svg)](https://zenodo.org/badge/latestdoi/239006399) 8 | 9 | ## Installation 10 | You can install the base class from PyPI with `pip`: 11 | 12 | ``` 13 | pip install bidsphysio.base 14 | ``` 15 | 16 | Alternatively, you can download the package and install the sub-package with `pip`: 17 | ``` 18 | mkdir /tmp/bidsphysio && \ 19 | curl -sSL https://github.com/cbinyu/bidsphysio/archive/master.tar.gz \ 20 | | tar -vxz -C /tmp/bidsphysio --strip-components=1 && \ 21 | cd /tmp/bidsphysio/bidsphysio.base/ && \ 22 | pip install . && \ 23 | cd / && \ 24 | rm -rf /tmp/bidsphysio 25 | ``` 26 | 27 | ## How to use in your own Python program 28 | After installing the module using `pip` (see [above](#installation "Installation") ), you can use it in your own Python program this way: 29 | ``` 30 | from bidsphysio.base.bidsphysio import (PhysioSignal, 31 | PhysioData) 32 | 33 | mySignal = PhysioSignal() 34 | ... 35 | ``` 36 | -------------------------------------------------------------------------------- /bidsphysio/info.py: -------------------------------------------------------------------------------- 1 | import os.path as op 2 | from os import scandir 3 | 4 | __version__ ="21.06.24" 5 | __author__ = "Pablo Velasco" 6 | __author_email__ = "pablo.velasco@nyu.edu" 7 | __url__ = "https://github.com/cbinyu/bidsphysio" 8 | __packagename__ = 'bidsphysio' 9 | __description__ = "Physio-to-BIDS Converter" 10 | __license__ = "MIT" 11 | __longdesc__ = """Converts physio data from either CMRR DICOM, CMRR log, Siemens PMU 12 | or AcqKnowledge file to BIDS physiological recording.""" 13 | 14 | CLASSIFIERS = [ 15 | 'Environment :: Console', 16 | 'Intended Audience :: Science/Research', 17 | 'License :: OSI Approved :: MIT License', 18 | 'Programming Language :: Python :: 3.6', 19 | 'Programming Language :: Python :: 3.7', 20 | 'Programming Language :: Python :: 3.8', 21 | 'Topic :: Scientific/Engineering' 22 | ] 23 | 24 | PYTHON_REQUIRES = ">=3.6" 25 | 26 | 27 | def find_subpackages(): 28 | thispath = op.dirname(__file__) or '.' 29 | 30 | # find_packages() doesn't find the bidsphysio.* sub-packages 31 | # because they don't have an __init__.py file. 32 | children_dirs = [ 33 | op.relpath(f.path, thispath) for f in scandir(thispath) 34 | if f.is_dir() 35 | ] 36 | return [d for d in children_dirs if d.startswith('bidsphysio.')] 37 | 38 | 39 | REQUIRES = find_subpackages() 40 | 41 | TESTS_REQUIRES = [ 42 | 'pytest' 43 | ] 44 | 45 | EXTRA_REQUIRES = { 46 | 'tests': TESTS_REQUIRES, 47 | } 48 | 49 | # Flatten the lists 50 | EXTRA_REQUIRES['all'] = sum(EXTRA_REQUIRES.values(), []) 51 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/pmu_VE11C_respiratory.tsv: -------------------------------------------------------------------------------- 1 | 1208.0000 2 | 1204.0000 3 | 1200.0000 4 | 1196.0000 5 | 1193.0000 6 | 1189.0000 7 | 1185.0000 8 | 1181.0000 9 | 1174.0000 10 | 1166.0000 11 | 1166.0000 12 | 1159.0000 13 | 1155.0000 14 | 1151.0000 15 | 1148.0000 16 | 1140.0000 17 | 1140.0000 18 | 1136.0000 19 | 1129.0000 20 | 1129.0000 21 | 1125.0000 22 | 1121.0000 23 | 1121.0000 24 | 1114.0000 25 | 1110.0000 26 | 1106.0000 27 | 1106.0000 28 | 1103.0000 29 | 1099.0000 30 | 1095.0000 31 | 1095.0000 32 | 1091.0000 33 | 1091.0000 34 | 1088.0000 35 | 1084.0000 36 | 1084.0000 37 | 1080.0000 38 | 1080.0000 39 | 1076.0000 40 | 1073.0000 41 | 1069.0000 42 | 1065.0000 43 | 1061.0000 44 | 1061.0000 45 | 1058.0000 46 | 1054.0000 47 | 1050.0000 48 | 1050.0000 49 | 1046.0000 50 | 1043.0000 51 | 1039.0000 52 | 1035.0000 53 | 1031.0000 54 | 1031.0000 55 | 1031.0000 56 | 1028.0000 57 | 1031.0000 58 | 1024.0000 59 | 1020.0000 60 | 1016.0000 61 | 1013.0000 62 | 1013.0000 63 | 1005.0000 64 | 1001.0000 65 | 1001.0000 66 | 998.0000 67 | 994.0000 68 | 994.0000 69 | 986.0000 70 | 983.0000 71 | 979.0000 72 | 979.0000 73 | 971.0000 74 | 971.0000 75 | 964.0000 76 | 964.0000 77 | 960.0000 78 | 956.0000 79 | 956.0000 80 | 953.0000 81 | 945.0000 82 | 945.0000 83 | 941.0000 84 | 938.0000 85 | 930.0000 86 | 930.0000 87 | 926.0000 88 | 923.0000 89 | 919.0000 90 | 919.0000 91 | 915.0000 92 | 911.0000 93 | 911.0000 94 | 908.0000 95 | 904.0000 96 | 904.0000 97 | 900.0000 98 | 896.0000 99 | 896.0000 100 | 893.0000 101 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/pmu_VE11C_respiratory.tsv: -------------------------------------------------------------------------------- 1 | 1208.0000 2 | 1204.0000 3 | 1200.0000 4 | 1196.0000 5 | 1193.0000 6 | 1189.0000 7 | 1185.0000 8 | 1181.0000 9 | 1174.0000 10 | 1166.0000 11 | 1166.0000 12 | 1159.0000 13 | 1155.0000 14 | 1151.0000 15 | 1148.0000 16 | 1140.0000 17 | 1140.0000 18 | 1136.0000 19 | 1129.0000 20 | 1129.0000 21 | 1125.0000 22 | 1121.0000 23 | 1121.0000 24 | 1114.0000 25 | 1110.0000 26 | 1106.0000 27 | 1106.0000 28 | 1103.0000 29 | 1099.0000 30 | 1095.0000 31 | 1095.0000 32 | 1091.0000 33 | 1091.0000 34 | 1088.0000 35 | 1084.0000 36 | 1084.0000 37 | 1080.0000 38 | 1080.0000 39 | 1076.0000 40 | 1073.0000 41 | 1069.0000 42 | 1065.0000 43 | 1061.0000 44 | 1061.0000 45 | 1058.0000 46 | 1054.0000 47 | 1050.0000 48 | 1050.0000 49 | 1046.0000 50 | 1043.0000 51 | 1039.0000 52 | 1035.0000 53 | 1031.0000 54 | 1031.0000 55 | 1031.0000 56 | 1028.0000 57 | 1031.0000 58 | 1024.0000 59 | 1020.0000 60 | 1016.0000 61 | 1013.0000 62 | 1013.0000 63 | 1005.0000 64 | 1001.0000 65 | 1001.0000 66 | 998.0000 67 | 994.0000 68 | 994.0000 69 | 986.0000 70 | 983.0000 71 | 979.0000 72 | 979.0000 73 | 971.0000 74 | 971.0000 75 | 964.0000 76 | 964.0000 77 | 960.0000 78 | 956.0000 79 | 956.0000 80 | 953.0000 81 | 945.0000 82 | 945.0000 83 | 941.0000 84 | 938.0000 85 | 930.0000 86 | 930.0000 87 | 926.0000 88 | 923.0000 89 | 919.0000 90 | 919.0000 91 | 915.0000 92 | 911.0000 93 | 911.0000 94 | 908.0000 95 | 904.0000 96 | 904.0000 97 | 900.0000 98 | 896.0000 99 | 896.0000 100 | 893.0000 101 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/pmu_VE11C_cardiac.tsv: -------------------------------------------------------------------------------- 1 | 1733.0000 2 | 1725.0000 3 | 1725.0000 4 | 1721.0000 5 | 1721.0000 6 | 1718.0000 7 | 1714.0000 8 | 1710.0000 9 | 1706.0000 10 | 1703.0000 11 | 1699.0000 12 | 1695.0000 13 | 1688.0000 14 | 1684.0000 15 | 1680.0000 16 | 1673.0000 17 | 1661.0000 18 | 1658.0000 19 | 1643.0000 20 | 1635.0000 21 | 1628.0000 22 | 1616.0000 23 | 1609.0000 24 | 1598.0000 25 | 1590.0000 26 | 1583.0000 27 | 1571.0000 28 | 1564.0000 29 | 1556.0000 30 | 1553.0000 31 | 1541.0000 32 | 1534.0000 33 | 1526.0000 34 | 1519.0000 35 | 1511.0000 36 | 1500.0000 37 | 1496.0000 38 | 1489.0000 39 | 1481.0000 40 | 1478.0000 41 | 1470.0000 42 | 1466.0000 43 | 1463.0000 44 | 1459.0000 45 | 1459.0000 46 | 1451.0000 47 | 1451.0000 48 | 1448.0000 49 | 1448.0000 50 | 1448.0000 51 | 1444.0000 52 | 1444.0000 53 | 1444.0000 54 | 1448.0000 55 | 1448.0000 56 | 1451.0000 57 | 1455.0000 58 | 1459.0000 59 | 1459.0000 60 | 1466.0000 61 | 1470.0000 62 | 1474.0000 63 | 1478.0000 64 | 1481.0000 65 | 1489.0000 66 | 1496.0000 67 | 1496.0000 68 | 1504.0000 69 | 1508.0000 70 | 1511.0000 71 | 1515.0000 72 | 1519.0000 73 | 1523.0000 74 | 1530.0000 75 | 1534.0000 76 | 1538.0000 77 | 1541.0000 78 | 1549.0000 79 | 1549.0000 80 | 1556.0000 81 | 1556.0000 82 | 1564.0000 83 | 1564.0000 84 | 1571.0000 85 | 1571.0000 86 | 1571.0000 87 | 1575.0000 88 | 1579.0000 89 | 1579.0000 90 | 1579.0000 91 | 1583.0000 92 | 1586.0000 93 | 1590.0000 94 | 1594.0000 95 | 1598.0000 96 | 1601.0000 97 | 1605.0000 98 | 1613.0000 99 | 1616.0000 100 | 1624.0000 101 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/pmu_VB15A_respiratory.tsv: -------------------------------------------------------------------------------- 1 | 1743.0000 2 | 1772.0000 3 | 1816.0000 4 | 1787.0000 5 | 1816.0000 6 | 1946.0000 7 | 1830.0000 8 | 1845.0000 9 | 1772.0000 10 | 1903.0000 11 | 1917.0000 12 | 1917.0000 13 | 1903.0000 14 | 1932.0000 15 | 1859.0000 16 | 1816.0000 17 | 2019.0000 18 | 2106.0000 19 | 2106.0000 20 | 1961.0000 21 | 1888.0000 22 | 1816.0000 23 | 1787.0000 24 | 1685.0000 25 | 1772.0000 26 | 2004.0000 27 | 2048.0000 28 | 2019.0000 29 | 1946.0000 30 | 1903.0000 31 | 1830.0000 32 | 1787.0000 33 | 1888.0000 34 | 1903.0000 35 | 2019.0000 36 | 2091.0000 37 | 2033.0000 38 | 1961.0000 39 | 1917.0000 40 | 1917.0000 41 | 1961.0000 42 | 2019.0000 43 | 2033.0000 44 | 2193.0000 45 | 2222.0000 46 | 2164.0000 47 | 2164.0000 48 | 1975.0000 49 | 2106.0000 50 | 2062.0000 51 | 2077.0000 52 | 2106.0000 53 | 2062.0000 54 | 2004.0000 55 | 1975.0000 56 | 2048.0000 57 | 2164.0000 58 | 2178.0000 59 | 2077.0000 60 | 2164.0000 61 | 2251.0000 62 | 2236.0000 63 | 2352.0000 64 | 2323.0000 65 | 2309.0000 66 | 2251.0000 67 | 2222.0000 68 | 2164.0000 69 | 2091.0000 70 | 2178.0000 71 | 2178.0000 72 | 2149.0000 73 | 2149.0000 74 | 2294.0000 75 | 2193.0000 76 | 2048.0000 77 | 2077.0000 78 | 2135.0000 79 | 2120.0000 80 | 2120.0000 81 | 2135.0000 82 | 2106.0000 83 | 2149.0000 84 | 1990.0000 85 | 2077.0000 86 | 2135.0000 87 | 1975.0000 88 | 1917.0000 89 | 1975.0000 90 | 2135.0000 91 | 2164.0000 92 | 2091.0000 93 | 2193.0000 94 | 2193.0000 95 | 2294.0000 96 | 2410.0000 97 | 2352.0000 98 | 2193.0000 99 | 2236.0000 100 | 2265.0000 101 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/tests/data/pmu_VE11C_cardiac.tsv: -------------------------------------------------------------------------------- 1 | 1733.0000 2 | 1725.0000 3 | 1725.0000 4 | 1721.0000 5 | 1721.0000 6 | 1718.0000 7 | 1714.0000 8 | 1710.0000 9 | 1706.0000 10 | 1703.0000 11 | 1699.0000 12 | 1695.0000 13 | 1688.0000 14 | 1684.0000 15 | 1680.0000 16 | 1673.0000 17 | 1661.0000 18 | 1658.0000 19 | 1643.0000 20 | 1635.0000 21 | 1628.0000 22 | 1616.0000 23 | 1609.0000 24 | 1598.0000 25 | 1590.0000 26 | 1583.0000 27 | 1571.0000 28 | 1564.0000 29 | 1556.0000 30 | 1553.0000 31 | 1541.0000 32 | 1534.0000 33 | 1526.0000 34 | 1519.0000 35 | 1511.0000 36 | 1500.0000 37 | 1496.0000 38 | 1489.0000 39 | 1481.0000 40 | 1478.0000 41 | 1470.0000 42 | 1466.0000 43 | 1463.0000 44 | 1459.0000 45 | 1459.0000 46 | 1451.0000 47 | 1451.0000 48 | 1448.0000 49 | 1448.0000 50 | 1448.0000 51 | 1444.0000 52 | 1444.0000 53 | 1444.0000 54 | 1448.0000 55 | 1448.0000 56 | 1451.0000 57 | 1455.0000 58 | 1459.0000 59 | 1459.0000 60 | 1466.0000 61 | 1470.0000 62 | 1474.0000 63 | 1478.0000 64 | 1481.0000 65 | 1489.0000 66 | 1496.0000 67 | 1496.0000 68 | 1504.0000 69 | 1508.0000 70 | 1511.0000 71 | 1515.0000 72 | 1519.0000 73 | 1523.0000 74 | 1530.0000 75 | 1534.0000 76 | 1538.0000 77 | 1541.0000 78 | 1549.0000 79 | 1549.0000 80 | 1556.0000 81 | 1556.0000 82 | 1564.0000 83 | 1564.0000 84 | 1571.0000 85 | 1571.0000 86 | 1571.0000 87 | 1575.0000 88 | 1579.0000 89 | 1579.0000 90 | 1579.0000 91 | 1583.0000 92 | 1586.0000 93 | 1590.0000 94 | 1594.0000 95 | 1598.0000 96 | 1601.0000 97 | 1605.0000 98 | 1613.0000 99 | 1616.0000 100 | 1624.0000 101 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/pmu_VB15A_respiratory.tsv: -------------------------------------------------------------------------------- 1 | 1743.0000 2 | 1772.0000 3 | 1816.0000 4 | 1787.0000 5 | 1816.0000 6 | 1946.0000 7 | 1830.0000 8 | 1845.0000 9 | 1772.0000 10 | 1903.0000 11 | 1917.0000 12 | 1917.0000 13 | 1903.0000 14 | 1932.0000 15 | 1859.0000 16 | 1816.0000 17 | 2019.0000 18 | 2106.0000 19 | 2106.0000 20 | 1961.0000 21 | 1888.0000 22 | 1816.0000 23 | 1787.0000 24 | 1685.0000 25 | 1772.0000 26 | 2004.0000 27 | 2048.0000 28 | 2019.0000 29 | 1946.0000 30 | 1903.0000 31 | 1830.0000 32 | 1787.0000 33 | 1888.0000 34 | 1903.0000 35 | 2019.0000 36 | 2091.0000 37 | 2033.0000 38 | 1961.0000 39 | 1917.0000 40 | 1917.0000 41 | 1961.0000 42 | 2019.0000 43 | 2033.0000 44 | 2193.0000 45 | 2222.0000 46 | 2164.0000 47 | 2164.0000 48 | 1975.0000 49 | 2106.0000 50 | 2062.0000 51 | 2077.0000 52 | 2106.0000 53 | 2062.0000 54 | 2004.0000 55 | 1975.0000 56 | 2048.0000 57 | 2164.0000 58 | 2178.0000 59 | 2077.0000 60 | 2164.0000 61 | 2251.0000 62 | 2236.0000 63 | 2352.0000 64 | 2323.0000 65 | 2309.0000 66 | 2251.0000 67 | 2222.0000 68 | 2164.0000 69 | 2091.0000 70 | 2178.0000 71 | 2178.0000 72 | 2149.0000 73 | 2149.0000 74 | 2294.0000 75 | 2193.0000 76 | 2048.0000 77 | 2077.0000 78 | 2135.0000 79 | 2120.0000 80 | 2120.0000 81 | 2135.0000 82 | 2106.0000 83 | 2149.0000 84 | 1990.0000 85 | 2077.0000 86 | 2135.0000 87 | 1975.0000 88 | 1917.0000 89 | 1975.0000 90 | 2135.0000 91 | 2164.0000 92 | 2091.0000 93 | 2193.0000 94 | 2193.0000 95 | 2294.0000 96 | 2410.0000 97 | 2352.0000 98 | 2193.0000 99 | 2236.0000 100 | 2265.0000 101 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/data/Physio_PULS.log: -------------------------------------------------------------------------------- 1 | UUID = a6df3c5a-4d96-475f-8335-6b26583fb2cd 2 | ScanDate = 20190114_143828 3 | LogVersion = EJA_1 4 | LogDataType = PULS 5 | SampleTime = 2 6 | 7 | ACQ_TIME_TICS CHANNEL VALUE SIGNAL 8 | 9 | 21083488 PULS 1834 10 | 21083490 PULS 1805 11 | 21083492 PULS 1782 12 | 21083494 PULS 1758 13 | 21083496 PULS 1739 14 | 21083498 PULS 1720 15 | 21083500 PULS 1696 16 | 21083502 PULS 1672 17 | 21083504 PULS 1644 18 | 21083506 PULS 1620 19 | 21083508 PULS 1596 20 | 21083510 PULS 1573 21 | 21083512 PULS 1554 22 | 21083514 PULS 1535 23 | 21083516 PULS 1520 24 | 21083518 PULS 1501 25 | 21083520 PULS 1482 26 | 21083522 PULS 1468 27 | 21083524 PULS 1454 28 | 21083526 PULS 1430 29 | 21083527 PULS 1411 30 | 21083529 PULS 1387 31 | 21083531 PULS 1368 32 | 21083533 PULS 1340 33 | 21083535 PULS 1321 34 | 21083537 PULS 1297 35 | 21083539 PULS 1278 36 | 21083541 PULS 1254 37 | 21083543 PULS 1240 38 | 21083545 PULS 1221 39 | 21083547 PULS 1207 40 | 21083549 PULS 1197 41 | 21083551 PULS 1178 42 | 21083553 PULS 1164 43 | 21083555 PULS 1145 44 | 21083557 PULS 1126 45 | 21083559 PULS 1107 46 | 21083561 PULS 1093 47 | 21083563 PULS 1083 48 | 21083565 PULS 1074 49 | 21083567 PULS 1060 50 | 21083569 PULS 1050 51 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/data/Physio_RESP.log: -------------------------------------------------------------------------------- 1 | UUID = a6df3c5a-4d96-475f-8335-6b26583fb2cd 2 | ScanDate = 20190114_143828 3 | LogVersion = EJA_1 4 | LogDataType = RESP 5 | SampleTime = 8 6 | 7 | ACQ_TIME_TICS CHANNEL VALUE SIGNAL 8 | 9 | 21083488 RESP 1728 10 | 21083496 RESP 1808 11 | 21083504 RESP 1872 12 | 21083512 RESP 1960 13 | 21083527 RESP 2112 14 | 21083535 RESP 2200 15 | 21083543 RESP 2272 16 | 21083551 RESP 2368 17 | 21083559 RESP 2448 18 | 21083567 RESP 2536 19 | 21083575 RESP 2616 20 | 21083583 RESP 2688 21 | 21083591 RESP 2752 22 | 21083599 RESP 2808 23 | 21083607 RESP 2864 24 | 21083615 RESP 2920 25 | 21083623 RESP 2992 26 | 21083631 RESP 3048 27 | 21083639 RESP 3080 28 | 21083647 RESP 3120 29 | 21083655 RESP 3160 30 | 21083663 RESP 3216 31 | 21083671 RESP 3248 32 | 21083679 RESP 3280 33 | 21083687 RESP 3312 34 | 21083695 RESP 3368 35 | 21083703 RESP 3440 36 | 21083711 RESP 3488 37 | 21083719 RESP 3544 38 | 21083727 RESP 3592 39 | 21083735 RESP 3632 40 | 21083743 RESP 3688 41 | 21083751 RESP 3728 42 | 21083759 RESP 3776 43 | 21083767 RESP 3816 44 | 21083775 RESP 3856 45 | 21083783 RESP 3896 46 | 21083791 RESP 3928 47 | 21083799 RESP 3960 48 | 21083807 RESP 3984 49 | 21083815 RESP 4008 50 | 21083823 RESP 4032 51 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See the LICENSE file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | from os import scandir 10 | 11 | from setuptools import setup, find_packages 12 | 13 | 14 | def main(): 15 | 16 | thispath = op.dirname(__file__) or '.' 17 | ldict = locals() 18 | 19 | # Get version and release info, which is all stored in info.py 20 | info_file = op.join(thispath, 'bidsphysio', 'info.py') 21 | with open(info_file) as infofile: 22 | exec(infofile.read(), globals(), ldict) 23 | 24 | # find_packages() doesn't find the bidsphysio.* sub-packages 25 | # because they don't have an __init__.py file. 26 | children_dirs = [ 27 | op.relpath(f.path,thispath) for f in scandir(thispath) 28 | if f.is_dir() 29 | ] 30 | bidsphysio_pkgs = [d for d in children_dirs if d.startswith('bidsphysio.')] 31 | 32 | setup( 33 | name=ldict['__packagename__'], 34 | author=ldict['__author__'], 35 | author_email=ldict['__author_email__'], 36 | version=ldict['__version__'], 37 | description=ldict['__description__'], 38 | long_description=ldict['__longdesc__'], 39 | license=ldict['__license__'], 40 | classifiers=ldict['CLASSIFIERS'], 41 | packages=find_packages(), 42 | entry_points={}, 43 | python_requires=ldict['PYTHON_REQUIRES'], 44 | install_requires=ldict['REQUIRES'], 45 | extras_require=ldict['EXTRA_REQUIRES'], 46 | ) 47 | 48 | 49 | if __name__ == '__main__': 50 | main() 51 | -------------------------------------------------------------------------------- /bidsphysio.session/README.md: -------------------------------------------------------------------------------- 1 | # bidsphysio.session 2 | Utilities to automatically assign physiological files for a whole session to the corresponding images. 3 | 4 | [![Docker image](https://img.shields.io/badge/docker-cbinyu/bidsphysio:latest-brightgreen.svg?logo=docker&style=flat)](https://hub.docker.com/r/cbinyu/bidsphysio/tags/) 5 | [![TravisCI](https://travis-ci.com/cbinyu/bidsphysio.svg?branch=master)](https://travis-ci.com/cbinyu/bidsphysio) 6 | [![CodeCoverage](https://codecov.io/gh/cbinyu/bidsphysio/branch/master/graph/badge.svg)](https://codecov.io/gh/cbinyu/bidsphysio) 7 | [![DOI](https://zenodo.org/badge/239006399.svg)](https://zenodo.org/badge/latestdoi/239006399) 8 | 9 | ## Installation 10 | You can install the bidsphysio.session subpackage from PyPI with `pip`: 11 | 12 | ``` 13 | pip install bidsphysio.session 14 | ``` 15 | 16 | Alternatively, you can download the package and install the sub-package with `pip`: 17 | ``` 18 | mkdir /tmp/bidsphysio && \ 19 | curl -sSL https://github.com/cbinyu/bidsphysio/archive/master.tar.gz \ 20 | | tar -vxz -C /tmp/bidsphysio --strip-components=1 && \ 21 | cd /tmp/bidsphysio/bidsphysio.session/ && \ 22 | pip install . && \ 23 | cd / && \ 24 | rm -rf /tmp/bidsphysio 25 | ``` 26 | 27 | ## How to use in your own Python program 28 | After installing the module using `pip` (see [above](#installation "Installation") ), you can use it in your own Python program this way: 29 | ```python 30 | from bidsphysio.session import session2bids 31 | from bidsphysio.acq2bids import acq2bidsphysio 32 | session2bids.convert_session( 33 | physio_files, 34 | acq2bidsphysio.acq2bids, 35 | bids_dir, 36 | sub=my_subject, 37 | overwrite=True, 38 | ) 39 | ``` 40 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/dcm_respiratory.tsv: -------------------------------------------------------------------------------- 1 | 3729.0000 0 2 | 3535.0000 0 3 | 3335.0000 0 4 | 3148.0000 0 5 | 2979.0000 0 6 | 2841.0000 0 7 | 2723.0000 0 8 | 2610.0000 0 9 | 2516.0000 0 10 | 2423.0000 0 11 | 2298.0000 0 12 | 2166.0000 0 13 | 2060.0000 0 14 | 1983.0000 0 15 | 1903.0000 0 16 | 1798.0000 0 17 | 1698.0000 0 18 | 1603.0000 0 19 | 1508.0000 0 20 | 1428.0000 0 21 | 1363.0000 0 22 | 1293.0000 0 23 | 1233.0000 0 24 | 1173.0000 0 25 | 1118.0000 0 26 | 1068.0000 0 27 | 1018.0000 0 28 | 953.0000 0 29 | 888.0000 0 30 | 828.0000 0 31 | 793.0000 0 32 | 758.0000 0 33 | 728.0000 0 34 | 698.0000 0 35 | 663.0000 0 36 | 628.0000 0 37 | 588.0000 0 38 | 553.0000 0 39 | 528.0000 0 40 | 508.0000 0 41 | 483.0000 0 42 | 458.0000 0 43 | 433.0000 0 44 | 403.0000 0 45 | 383.0000 0 46 | 363.0000 0 47 | 328.0000 0 48 | 313.0000 0 49 | 313.0000 0 50 | 298.0000 0 51 | 263.0000 0 52 | 223.0000 0 53 | 183.0000 0 54 | 133.0000 0 55 | 98.0000 0 56 | 58.0000 0 57 | 28.0000 0 58 | 8.0000 0 59 | 0.0000 0 60 | 13.0000 0 61 | 33.0000 0 62 | 58.0000 0 63 | 58.0000 0 64 | 68.0000 0 65 | 73.0000 0 66 | 88.0000 0 67 | 108.0000 0 68 | 128.0000 0 69 | 163.0000 0 70 | 178.0000 0 71 | 193.0000 0 72 | 213.0000 0 73 | 233.0000 0 74 | 238.0000 0 75 | 248.0000 0 76 | 253.0000 0 77 | 268.0000 0 78 | 288.0000 0 79 | 303.0000 0 80 | 328.0000 0 81 | 353.0000 0 82 | 373.0000 0 83 | 378.0000 0 84 | 378.0000 0 85 | 403.0000 0 86 | 438.0000 0 87 | 448.0000 0 88 | 438.0000 0 89 | 413.0000 0 90 | 383.0000 0 91 | 353.0000 0 92 | 328.0000 0 93 | 313.0000 0 94 | 303.0000 0 95 | 298.0000 0 96 | 303.0000 0 97 | 323.0000 0 98 | 358.0000 0 99 | 373.0000 0 100 | 383.0000 0 101 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See ../LICENSE file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'acq2bids', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | entry_points={'console_scripts': [ 36 | 'acq2bidsphysio=bidsphysio.acq2bids.acq2bidsphysio:main', 37 | 'acqsession2bids=bidsphysio.acq2bids.acqsession2bids:main', 38 | ]}, 39 | python_requires=ldict['PYTHON_REQUIRES'], 40 | install_requires=ldict['REQUIRES'], 41 | extras_require=ldict['EXTRA_REQUIRES'], 42 | package_data={ 43 | 'bidsphysio.acq2bids.tests': [ 44 | op.join('data', '*.acq'), 45 | op.join('data', '*.tsv') 46 | ], 47 | } 48 | ) 49 | 50 | 51 | if __name__ == '__main__': 52 | main() 53 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See ../LICENSE file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'edf2bids', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | entry_points={'console_scripts': [ 36 | 'edf2bidsphysio=bidsphysio.edf2bids.edf2bidsphysio:main', 37 | 'edfsession2bids=bidsphysio.edf2bids.edfsession2bids:main', 38 | ]}, 39 | python_requires=ldict['PYTHON_REQUIRES'], 40 | install_requires=ldict['REQUIRES'], 41 | extras_require=ldict['EXTRA_REQUIRES'], 42 | package_data={ 43 | 'bidsphysio.edf2bids.tests': [ 44 | op.join('data', '*.edf'), 45 | op.join('data', '*.tsv') 46 | ], 47 | } 48 | ) 49 | 50 | 51 | if __name__ == '__main__': 52 | main() 53 | -------------------------------------------------------------------------------- /bidsphysio.pmu2bids/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See ../LICENSE file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'pmu2bids', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | entry_points={'console_scripts': [ 36 | 'pmu2bidsphysio=bidsphysio.pmu2bids.pmu2bidsphysio:main', 37 | ]}, 38 | python_requires=ldict['PYTHON_REQUIRES'], 39 | install_requires=ldict['REQUIRES'], 40 | extras_require=ldict['EXTRA_REQUIRES'], 41 | package_data={ 42 | 'bidsphysio.pmu2bids.tests': [ 43 | op.join('data', '*.resp'), 44 | op.join('data', '*.puls'), 45 | op.join('data', '*.tsv'), 46 | op.join('data', '*.acq'), 47 | ], 48 | } 49 | ) 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/tests/data/dcm_cardiac.tsv: -------------------------------------------------------------------------------- 1 | 2228.0000 0 2 | 2205.0000 0 3 | 2183.0000 0 4 | 2164.0000 0 5 | 2141.0000 0 6 | 2119.0000 0 7 | 2096.0000 0 8 | 2078.0000 0 9 | 2055.0000 0 10 | 2040.0000 0 11 | 2021.0000 0 12 | 2003.0000 0 13 | 1988.0000 0 14 | 1976.0000 0 15 | 1961.0000 0 16 | 1946.0000 0 17 | 1935.0000 0 18 | 1920.0000 0 19 | 1909.0000 0 20 | 1898.0000 0 21 | 1890.0000 0 22 | 1883.0000 0 23 | 1875.0000 0 24 | 1871.0000 0 25 | 1868.0000 0 26 | 1868.0000 0 27 | 1868.0000 0 28 | 1864.0000 0 29 | 1864.0000 0 30 | 1864.0000 0 31 | 1868.0000 0 32 | 1864.0000 0 33 | 1864.0000 0 34 | 1864.0000 0 35 | 1864.0000 0 36 | 1864.0000 0 37 | 1864.0000 0 38 | 1864.0000 0 39 | 1864.0000 0 40 | 1864.0000 0 41 | 1864.0000 0 42 | 1860.0000 0 43 | 1860.0000 0 44 | 1860.0000 0 45 | 1856.0000 0 46 | 1856.0000 0 47 | 1853.0000 0 48 | 1856.0000 0 49 | 1856.0000 0 50 | 1856.0000 0 51 | 1856.0000 0 52 | 1856.0000 0 53 | 1856.0000 0 54 | 1856.0000 0 55 | 1856.0000 0 56 | 1853.0000 0 57 | 1849.0000 0 58 | 1849.0000 0 59 | 1845.0000 0 60 | 1841.0000 0 61 | 1838.0000 0 62 | 1838.0000 0 63 | 1834.0000 0 64 | 1830.0000 0 65 | 1826.0000 0 66 | 1819.0000 0 67 | 1811.0000 0 68 | 1808.0000 0 69 | 1800.0000 0 70 | 1796.0000 0 71 | 1793.0000 0 72 | 1785.0000 0 73 | 1785.0000 0 74 | 1781.0000 0 75 | 1778.0000 0 76 | 1778.0000 0 77 | 1774.0000 0 78 | 1774.0000 0 79 | 1778.0000 0 80 | 1781.0000 0 81 | 1793.0000 0 82 | 1804.0000 0 83 | 1815.0000 0 84 | 1830.0000 0 85 | 1853.0000 0 86 | 1875.0000 0 87 | 1905.0000 0 88 | 1931.0000 0 89 | 1969.0000 0 90 | 2003.0000 0 91 | nan 0 92 | 2089.0000 0 93 | 2138.0000 0 94 | 2183.0000 0 95 | 2228.0000 0 96 | 2276.0000 0 97 | 2321.0000 0 98 | 2366.0000 0 99 | 2411.0000 0 100 | 2456.0000 0 101 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See ../LICENSE file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'dcm2bids', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | entry_points={'console_scripts': [ 36 | 'dcm2bidsphysio=bidsphysio.dcm2bids.dcm2bidsphysio:main', 37 | 'dcmsession2bids=bidsphysio.dcm2bids.dcmsession2bids:main', 38 | ]}, 39 | python_requires=ldict['PYTHON_REQUIRES'], 40 | install_requires=ldict['REQUIRES'], 41 | extras_require=ldict['EXTRA_REQUIRES'], 42 | package_data={ 43 | 'bidsphysio.dcm2bids.tests': [ 44 | op.join('data', '*.dcm'), 45 | op.join('data', '*.log'), 46 | op.join('data', '*.tsv') 47 | ], 48 | } 49 | ) 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | -------------------------------------------------------------------------------- /bidsphysio.physio2bids/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 3 | # 4 | # See ../LICENSE file for the copyright and license terms. 5 | # 6 | # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 7 | 8 | import os.path as op 9 | 10 | from setuptools import setup, find_packages 11 | 12 | 13 | def main(): 14 | 15 | thispath = op.dirname(__file__) 16 | ldict = locals() 17 | 18 | # Get version and release info, which is all stored in info.py 19 | info_file = op.join(thispath, 'bidsphysio', 'physio2bids', 'info.py') 20 | with open(info_file) as infofile: 21 | exec(infofile.read(), globals(), ldict) 22 | 23 | 24 | setup( 25 | name=ldict['__packagename__'], 26 | author=ldict['__author__'], 27 | author_email=ldict['__author_email__'], 28 | version=ldict['__version__'], 29 | description=ldict['__description__'], 30 | long_description=ldict['__longdesc__'], 31 | license=ldict['__license__'], 32 | classifiers=ldict['CLASSIFIERS'], 33 | packages=find_packages(), 34 | namespace_packages=['bidsphysio'], 35 | entry_points={'console_scripts': [ 36 | 'physio2bidsphysio=bidsphysio.physio2bids.physio2bidsphysio:main', 37 | ]}, 38 | python_requires=ldict['PYTHON_REQUIRES'], 39 | install_requires=ldict['REQUIRES'], 40 | extras_require=ldict['EXTRA_REQUIRES'], 41 | package_data={ 42 | 'bidsphysio.physio2bids.tests': [ 43 | op.join('data', '*.acq'), 44 | op.join('data', '*.dcm'), 45 | op.join('data', '*.resp'), 46 | op.join('data', '*.puls'), 47 | op.join('data', '*.tsv') 48 | ], 49 | } 50 | ) 51 | 52 | 53 | if __name__ == '__main__': 54 | main() 55 | -------------------------------------------------------------------------------- /bidsphysio.base/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | """ Tests for the module "utils.py" """ 2 | 3 | from shutil import (copyfile, 4 | copyfileobj) 5 | import gzip 6 | 7 | import pytest 8 | 9 | from bidsphysio.base.utils import (check_bidsphysio_outputs, 10 | get_physio_TRs) 11 | from .utils import (TESTS_DATA_PATH, 12 | EXPECTED_TR) 13 | 14 | ### Globals ### 15 | CHECK_OUTPUTS_FILE_PREFIX = 'test_nan_TR' 16 | 17 | def test_check_bidsphysio_outputs(tmpdir): 18 | """ 19 | Tests for check_bidsphysio_outputs 20 | """ 21 | json_files = list(TESTS_DATA_PATH.glob(CHECK_OUTPUTS_FILE_PREFIX + '*.json')) 22 | data_files = list(TESTS_DATA_PATH.glob(CHECK_OUTPUTS_FILE_PREFIX + '*.tsv.gz')) 23 | # we only expect one file for each 24 | assert len(json_files) == len(data_files) == 1 25 | 26 | # take first match and remove '_physio' from end: 27 | j_file = json_files[0].stem.split('_physio')[-2] 28 | true_bids_prefix = TESTS_DATA_PATH / j_file 29 | 30 | # 1) Check that when files don't match, the function fails 31 | # (The function has its own "assert" lines) 32 | with pytest.raises(AssertionError) as e_info: 33 | check_bidsphysio_outputs(true_bids_prefix, 34 | ['cardiac'], 35 | TESTS_DATA_PATH / 'foo') 36 | 37 | # Check that when we compare some files against themselves, it passes. 38 | # The expectedDataFiles (from the third argument) are supposed to be 39 | # unzipped, so make a copy to a temp folder and unzip: 40 | f = json_files[0] 41 | copyfile(f, tmpdir / f.name) 42 | f = data_files[0] 43 | with gzip.open(f, 'r') as f_in, \ 44 | open(tmpdir / f.name.split('.gz')[0], 'wb') as f_out: 45 | copyfileobj(f_in, f_out) 46 | 47 | check_bidsphysio_outputs(true_bids_prefix, 48 | ['external_trigger'], 49 | tmpdir / f.name.split('.tsv.gz')[0]) 50 | 51 | 52 | def test_get_physio_TRs(): 53 | """ 54 | Check that we get the expected result. 55 | We'll use a file that has NaN's, and it still should work 56 | """ 57 | TRs = get_physio_TRs(TESTS_DATA_PATH / 'test_nan_TR') 58 | assert isinstance(TRs, list) 59 | assert TRs == [EXPECTED_TR] 60 | 61 | -------------------------------------------------------------------------------- /bidsphysio.acq2bids/tests/test_acqsession2bids.py: -------------------------------------------------------------------------------- 1 | """ Tests for the module "acqsession2bids.py" """ 2 | 3 | import sys 4 | 5 | import pytest 6 | 7 | from bidsphysio.session import session2bids 8 | from bidsphysio.acq2bids import acqsession2bids 9 | 10 | MOCK_MESSAGE = 'mock_convert_session called' 11 | 12 | 13 | ### Fixtures ### 14 | 15 | @pytest.fixture 16 | def mock_conversion(monkeypatch): 17 | """ 18 | Pretend we run session2bids.convert_session, but do nothing 19 | This allows us to test the correct behavior of the runner without 20 | actually running anything: just the instructions in the runner 21 | before the call to session2bids.convert_session 22 | """ 23 | 24 | def mock_convert_session(*args, **kwargs): 25 | print(MOCK_MESSAGE) 26 | pass 27 | 28 | monkeypatch.setattr(session2bids, "convert_session", mock_convert_session) 29 | 30 | 31 | ### Tests ### 32 | 33 | def test_main_args( 34 | monkeypatch, 35 | tmpdir, 36 | mock_conversion, 37 | capfd 38 | ): 39 | """ Tests for "main" 40 | Just check the arguments, etc. 41 | """ 42 | # TODO: write a function to run the tests that are almost the same 43 | # 1) "infolder" doesn't exist: 44 | infolder = str(tmpdir / 'boo') 45 | bidsfolder = str(tmpdir / 'mybidsdir') 46 | args = ( 47 | 'acqsession2bids -i {infolder} -b {bf} -s {sub} --overwrite'.format( 48 | infolder=infolder, 49 | bf=bidsfolder, 50 | sub='01' 51 | ) 52 | ).split(' ') 53 | monkeypatch.setattr(sys, 'argv', args) 54 | with pytest.raises(NotADirectoryError) as e_info: 55 | acqsession2bids.main() 56 | assert str(e_info.value).endswith(' folder not found') 57 | assert str(e_info.value).split(' folder not found')[0] == infolder 58 | 59 | # 2) "infolder" does exist, but output directory doesn't exist: 60 | args[args.index('-i') + 1] = str(tmpdir) 61 | monkeypatch.setattr(sys, 'argv', args) 62 | with pytest.raises(NotADirectoryError) as e_info: 63 | acqsession2bids.main() 64 | assert str(e_info.value).endswith(' folder not found') 65 | assert str(e_info.value).split(' folder not found')[0] == bidsfolder 66 | 67 | # 3) both "infolder" and "bidsfolder" exist: 68 | args[args.index('-b') + 1] = str(tmpdir) 69 | monkeypatch.setattr(sys, 'argv', args) 70 | acqsession2bids.main() 71 | 72 | # make sure we are calling the mock_conversion: 73 | assert capfd.readouterr().out == MOCK_MESSAGE + '\n' 74 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/tests/test_dcmsession2bids.py: -------------------------------------------------------------------------------- 1 | """ Tests for the module "dcmsession2bids.py" """ 2 | 3 | import sys 4 | 5 | import pytest 6 | 7 | from bidsphysio.session import session2bids 8 | from bidsphysio.dcm2bids import dcmsession2bids 9 | 10 | MOCK_MESSAGE = 'mock_convert_session called' 11 | 12 | 13 | ### Fixtures ### 14 | 15 | @pytest.fixture 16 | def mock_conversion(monkeypatch): 17 | """ 18 | Pretend we run session2bids.convert_session, but do nothing 19 | This allows us to test the correct behavior of the runner without 20 | actually running anything: just the instructions in the runner 21 | before the call to session2bids.convert_session 22 | """ 23 | 24 | def mock_convert_session(*args, **kwargs): 25 | print(MOCK_MESSAGE) 26 | pass 27 | 28 | monkeypatch.setattr(session2bids, "convert_session", mock_convert_session) 29 | 30 | 31 | ### Tests ### 32 | 33 | def test_main_args( 34 | monkeypatch, 35 | tmpdir, 36 | mock_conversion, 37 | capfd 38 | ): 39 | """ Tests for "main" 40 | Just check the arguments, etc. 41 | """ 42 | # TODO: write a function to run the tests that are almost the same 43 | # 1) "infolder" doesn't exist: 44 | infolder = str(tmpdir / 'boo') 45 | bidsfolder = str(tmpdir / 'mybidsdir') 46 | args = ( 47 | 'dcmsession2bids -i {infolder} -b {bf} -s {sub} --overwrite'.format( 48 | infolder=infolder, 49 | bf=bidsfolder, 50 | sub='01' 51 | ) 52 | ).split(' ') 53 | monkeypatch.setattr(sys, 'argv', args) 54 | with pytest.raises(NotADirectoryError) as e_info: 55 | dcmsession2bids.main() 56 | assert str(e_info.value).endswith(' folder not found') 57 | assert str(e_info.value).split(' folder not found')[0] == infolder 58 | 59 | # 2) "infolder" does exist, but output directory doesn't exist: 60 | args[args.index('-i') + 1] = str(tmpdir) 61 | monkeypatch.setattr(sys, 'argv', args) 62 | with pytest.raises(NotADirectoryError) as e_info: 63 | dcmsession2bids.main() 64 | assert str(e_info.value).endswith(' folder not found') 65 | assert str(e_info.value).split(' folder not found')[0] == bidsfolder 66 | 67 | # 3) both "infolder" and "bidsfolder" exist: 68 | args[args.index('-b') + 1] = str(tmpdir) 69 | monkeypatch.setattr(sys, 'argv', args) 70 | dcmsession2bids.main() 71 | 72 | # make sure we are calling the mock_conversion: 73 | assert capfd.readouterr().out == MOCK_MESSAGE + '\n' 74 | -------------------------------------------------------------------------------- /bidsphysio.edf2bids/tests/test_edfsession2bids.py: -------------------------------------------------------------------------------- 1 | """ Tests for the module "edfsession2bids.py" """ 2 | 3 | import sys 4 | 5 | import pytest 6 | 7 | from bidsphysio.session import session2bids 8 | from bidsphysio.edf2bids import edfsession2bids 9 | 10 | MOCK_MESSAGE = 'mock_convert_edf_session called' 11 | 12 | ### Fixtures ### 13 | 14 | @pytest.fixture 15 | def mock_edf_conversion(monkeypatch): 16 | """ 17 | Pretend we run session2bids.convert_edf_session, but do nothing 18 | This allows us to test the correct behavior of the runner without 19 | actually running anything: just the instructions in the runner 20 | before the call to session2bids.convert_edf_session 21 | """ 22 | def mock_convert_edf_session(*args, **kwargs): 23 | print(MOCK_MESSAGE) 24 | pass 25 | 26 | monkeypatch.setattr(session2bids, "convert_edf_session", mock_convert_edf_session) 27 | 28 | 29 | ### Tests ### 30 | 31 | def test_main_args( 32 | monkeypatch, 33 | tmpdir, 34 | mock_edf_conversion, 35 | capfd 36 | ): 37 | """ Tests for "main" 38 | Just check the arguments, etc. 39 | """ 40 | # TODO: write a function to run the tests that are almost the same 41 | # 1) "infolder" doesn't exist: 42 | infolder = str(tmpdir / 'boo') 43 | bidsfolder = str(tmpdir / 'mybidsdir') 44 | args = ( 45 | 'edfsession2bids -i {infolder} -b {bf} -s {sub}'.format( 46 | infolder=infolder, 47 | bf=bidsfolder, 48 | sub='01' 49 | ) 50 | ).split(' ') 51 | monkeypatch.setattr(sys, 'argv',args) 52 | with pytest.raises(NotADirectoryError) as e_info: 53 | edfsession2bids.main() 54 | assert str(e_info.value).endswith(' folder not found') 55 | assert str(e_info.value).split(' folder not found')[0] == infolder 56 | 57 | # 2) "infolder" does exist, but output directory doesn't exist: 58 | args[ args.index('-i')+1 ] = str(tmpdir) 59 | monkeypatch.setattr(sys, 'argv',args) 60 | with pytest.raises(NotADirectoryError) as e_info: 61 | edfsession2bids.main() 62 | assert str(e_info.value).endswith(' folder not found') 63 | assert str(e_info.value).split(' folder not found')[0] == bidsfolder 64 | 65 | # 3) both "infolder" and "bidsfolder" exist: 66 | args[ args.index('-b')+1 ] = str(tmpdir) 67 | monkeypatch.setattr(sys, 'argv',args) 68 | edfsession2bids.main() 69 | 70 | # make sure we are not calling the mock_edf_conversion, but the real one: 71 | assert capfd.readouterr().out == MOCK_MESSAGE + '\n' 72 | -------------------------------------------------------------------------------- /bidsphysio.dcm2bids/README.md: -------------------------------------------------------------------------------- 1 | # bidsphysio.dcm2bids 2 | Converts physio data from a CMRR sequence saved in a DICOM file to BIDS physiological recording 3 | 4 | [![Docker image](https://img.shields.io/badge/docker-cbinyu/bidsphysio:latest-brightgreen.svg?logo=docker&style=flat)](https://hub.docker.com/r/cbinyu/bidsphysio/tags/) 5 | [![TravisCI](https://travis-ci.com/cbinyu/bidsphysio.svg?branch=master)](https://travis-ci.com/cbinyu/bidsphysio) 6 | [![CodeCoverage](https://codecov.io/gh/cbinyu/bidsphysio/branch/master/graph/badge.svg)](https://codecov.io/gh/cbinyu/bidsphysio) 7 | [![DOI](https://zenodo.org/badge/239006399.svg)](https://zenodo.org/badge/latestdoi/239006399) 8 | 9 | ## Usage 10 | ``` 11 | dcm2bidsphysio --infile --bidsprefix [--verbose] 12 | ``` 13 | 14 | Example: 15 | ``` 16 | dcm2bidsphysio --infile myPhysio.dcm \ 17 | --bidsprefix BIDSfolder/sub-01/func/sub-01_task-REST_run-1 18 | ``` 19 | 20 | ## Arguments 21 | * `` CMRR physio DICOM file (`<.dcm>`) with the physiological 22 | recordings. 23 | * `` is the prefix that will be used for the BIDS physiology files. If all physiological recordings have the same sampling rate and starting time, the script will save the files: `_physio.json` and `_physio.tsv.gz`. If the physiological signals have different sampling rates and/or starting times, the script will save the files: `_recording-