Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Restructure #38

Merged
merged 43 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e2dec6a
Added heudiconv link
Nov 20, 2019
f5dfaf0
Added main call
Nov 20, 2019
89240f9
Started writing classes for phys2bids
Nov 21, 2019
e936b58
Start writing methods
Nov 21, 2019
9bc82f4
Turned a string into f string
Nov 21, 2019
afad556
Finished object organisation
Nov 21, 2019
dcb2419
Just flake8ed the eof
Nov 21, 2019
79acc27
Started writing interface for acq files
Nov 21, 2019
c6d69e3
changed name of objects
Nov 21, 2019
b94def5
Started moving acq related code into proper interface file
Nov 21, 2019
b603285
Removed parent class, added start_time in output
Nov 22, 2019
70e6965
Adapted print_info to general input object, moved into utils, improve…
Nov 22, 2019
4497f82
Changed default tr
Nov 22, 2019
9f4ea24
removed unnecessary steps and corrected export error
Nov 22, 2019
6bb89fa
Changed function has_data_size into has_size, added ch_amount to obje…
Nov 22, 2019
600c0f9
Created new function to automatically detect extension of input file …
Nov 22, 2019
be37a34
Started adjusting to new objects and functions.
Nov 22, 2019
07f4245
Pseudo code and docstrings
Nov 25, 2019
294e122
Completed docstrings
Nov 25, 2019
f4223db
Added blueprint output and method to populate it from blueprint input
Nov 25, 2019
2d57c5a
added methods to delete an indexed element and to return an indexed e…
Nov 25, 2019
11c689c
Added creation of one class property (number of tr found)
Nov 25, 2019
75e6387
Changed heuristic to add "recording" label
Nov 25, 2019
fd3413e
Adapted channel selection for new objects, added frequency splitting …
Nov 25, 2019
4f806c0
Renamed parser argument and changed default
Nov 26, 2019
28e0406
Improved docstrings, added method to rename channels in blueprint_input
Nov 26, 2019
cfc333e
renamed "table_header" into "ch_name", added a check on input file ex…
Nov 26, 2019
2c61fa1
Addressed @eurunuela 's review to PR #38
Nov 26, 2019
9b139d6
Added more docstrings, Keep addressing @eurunuela's review to PR #38,…
Nov 26, 2019
c924c32
Addressed @rmarkello 's reviews in PR #38
Nov 26, 2019
e641231
Changed ch_name default from Nonetype to empty list
Nov 26, 2019
d355bbd
Assignment of empty `recording`
Nov 27, 2019
b970ae3
Addressing @vinferrer 's review in PR #38, moving method from `utils.…
Nov 27, 2019
a18b2b7
Keep addressing @vinferrer 's PR #38 review
Nov 27, 2019
a257472
Bug fix due to external commit
Nov 27, 2019
056e0e1
Bug fixes
Nov 27, 2019
d896d5b
Added check on extension entry in check_input_ext prior to Path().wit…
Nov 27, 2019
61b7f32
Added heuristic for acq test file
Nov 27, 2019
5ad1f3f
Bug fixing post-reviews
Nov 28, 2019
3d1a47b
Corrected handling of path objects while using heuristics
Nov 28, 2019
5b7bd9d
Changed use of heuristics
Nov 28, 2019
a80c6e9
Improved heuristic files
Nov 28, 2019
42da7bd
Merge branch 'master' into restructure
Nov 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions phys2bids/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _get_parser():
type=int,
help=('The number corresponding to the trigger channel.'
' Channel numbering starts with 0'),
default=1)
default=0)
optional.add_argument('-chsel', '--channel-selection',
dest='chsel',
nargs='*',
Expand All @@ -89,20 +89,18 @@ def _get_parser():
dest='tr',
type=float,
help='TR of sequence in seconds.',
default=1)
default=0)
optional.add_argument('-thr', '--threshold',
dest='thr',
type=float,
help='Threshold used for trigger detection.',
default=2.5)
optional.add_argument('-tbhd', '--table-header',
dest='table_header',
optional.add_argument('-chnames', '--channel-names',
dest='ch_name',
nargs='*',
type=str,
help='Columns header (for json file).',
# #!# Has to go to empty list
default=['time', 'respiratory_chest', 'trigger',
'cardiac', 'respiratory_CO2', 'respiratory_O2'])
default=[])

optional.add_argument('-v', '--version', action='version',
version=('%(prog)s ' + __version__))
Expand Down
54 changes: 54 additions & 0 deletions phys2bids/heuristics/heur_test_acq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sys
import fnmatch


def heur(physinfo, name, task='', acq='', direct='', rec='', run=''):
# ############################## #
# ## Modify here! ## #
# ## ## #
# ## Possible variables are: ## #
# ## -task (required) ## #
# ## -run ## #
# ## -rec ## #
# ## -acq ## #
# ## -direct ## #
# ## ## #
# ## ## #
# ## See example below ## #
# ############################## #

if fnmatch.fnmatchcase(physinfo, '*samefreq*.acq'):
task = 'test'
run = '00'
rec = 'biopac'
elif physinfo == 'Example':
task = 'rest'
run = '01'
acq = 'resp'
# ############################## #
# ## Don't modify below this! ## #
# ############################## #
else:
# #!# Transform sys.exit in debug warnings or raiseexceptions!
# #!# Make all of the above a dictionary
sys.exit()

if not task:
sys.exit()

name = name + '_task-' + task

# filename spec: sub-<label>[_ses-<label>]_task-<label>[_acq-<label>][_ce-<label>][_dir-<label>][_rec-<label>][_run-<index>][_recording-<label>]_physio
if acq:
name = name + '_acq-' + acq

if direct:
name = name + '_dir-' + direct

if rec:
name = name + '_rec-' + rec

if run:
name = name + '_run-' + run

return name
32 changes: 32 additions & 0 deletions phys2bids/interfaces/acq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
phys2bids interface for acqknowledge files.
"""
from bioread import read_file

from phys2bids.physio_obj import BlueprintInput


def populate_phys_input(filename, chtrig):
"""
Populate object phys_input
"""

data = read_file(filename).channels

freq = [data[chtrig].samples_per_second] * 2
timeseries = [data[chtrig].time_index, data[chtrig].data]
units = ['s', data[chtrig].units]
names = ['time', 'trigger']

for k, ch in enumerate(data):
if k != chtrig:
print(f'{k:02d}. {ch}')
timeseries.append(ch.data)
freq.append(ch.samples_per_second)
units.append(ch.units)
names.append(ch.name)

return BlueprintInput(timeseries, freq, names, units)
Loading