Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 29, 2023
1 parent 7c6d9d7 commit bb48dd9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion phys2bids/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _get_parser():
"Time offset in seconds. Default for GE is 30 seconds. ",
default=30.0,
)

optional.add_argument(
"-thr",
"--threshold",
Expand Down
47 changes: 24 additions & 23 deletions phys2bids/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
"""phys2bids interfaces for loading extension files."""

import pdb
import logging
import pdb
import warnings
from copy import deepcopy
from itertools import groupby
Expand Down Expand Up @@ -215,7 +215,6 @@ def read_header_and_channels(filename):
header.append(line)
continue


# Read in the rest paying attention to possible differences
if "Interval=" in str(header[0]):
# Not specifying delimiters will ignore comments
Expand Down Expand Up @@ -506,27 +505,27 @@ def load_gep(filename, inifreq=None, pretime=30.0):
# Add column for file given by user
if "PPGData" in filename:
freq = [100, 100, 100]
# freq = [50, 50, 50]
# freq = [50, 50, 50]
names.append("cardiac")
elif "RESPData" in filename:
freq = [25, 25, 25]
names.append("respiratory")
elif "ECGData" in filename:
freq = [1000, 1000, 1000]
names.append("cardiac")

# if frequency specified in call, use that instead
if inifreq :
if inifreq:
freq = [inifreq, inifreq, inifreq]

# Load in user file data
data = [np.loadtxt(filename)]

# Calculate time in seconds for first input (starts from -30s)
interval = 1 / freq[0]
duration = data[0].shape[0] * interval
#t_ch = np.ogrid[-30 : duration - 30 : interval]
t_ch = np.ogrid[0 : duration : interval]
# t_ch = np.ogrid[-30 : duration - 30 : interval]
t_ch = np.ogrid[0:duration:interval]

# Find and add additional data files
filename = Path(filename)
Expand All @@ -535,31 +534,33 @@ def load_gep(filename, inifreq=None, pretime=30.0):
if not len(fnames) == 0:
for fname in fnames:
if "PPGData" in fname:
if inifreq :
freq.append(inifreq)
else :
freq.append(100)
if inifreq:
freq.append(inifreq)
else:
freq.append(100)
names.append("cardiac")
data.append(np.loadtxt(fname))
elif "RESPData" in fname:
if inifreq :
freq.append(inifreq)
else :
freq.append(25)
if inifreq:
freq.append(inifreq)
else:
freq.append(25)
names.append("respiratory")
data.append(np.loadtxt(fname))
elif "ECGData" in fname:
if inifreq :
freq.append(inifreq)
else :
freq.append(1000)
if inifreq:
freq.append(inifreq)
else:
freq.append(1000)
names.append("cardiac")
data.append(np.loadtxt(fname))

# Create trigger channel
trigger = np.hstack((np.zeros(int(pretime / interval)), np.ones(int((duration - pretime) / interval))))
#trigger = np.hstack((np.zeros(int(30 / interval)), np.ones(int((duration - 30) / interval))))
#trigger = np.hstack( np.ones(int((duration) / interval)))
trigger = np.hstack(
(np.zeros(int(pretime / interval)), np.ones(int((duration - pretime) / interval)))
)
# trigger = np.hstack((np.zeros(int(30 / interval)), np.ones(int((duration - 30) / interval))))
# trigger = np.hstack( np.ones(int((duration) / interval)))

# Create final list of timeseries
timeseries = [t_ch, trigger]
Expand Down
4 changes: 2 additions & 2 deletions phys2bids/phys2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def phys2bids(
debug=False,
quiet=False,
freq=None,
pretime=None
pretime=None,
):
"""
Run main workflow of phys2bids.
Expand Down Expand Up @@ -261,7 +261,7 @@ def phys2bids(
elif ftype == "gep":
from phys2bids.io import load_gep

phys_in = load_gep(infile, inifreq=freq, pretime=pretime )
phys_in = load_gep(infile, inifreq=freq, pretime=pretime)

LGR.info("Checking that units of measure are BIDS compatible")
for index, unit in enumerate(phys_in.units):
Expand Down
2 changes: 1 addition & 1 deletion phys2bids/physio_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def check_trigger_amount(self, thr=None, num_timepoints_expected=0, tr=0):
# is "off".
thr = np.mean(trigger)
flag = 1
# drg - modified to >= rather than >
# drg - modified to >= rather than >
timepoints = trigger >= thr
# drg - also removed threshold difference that looks at consecutive diffs
# num_timepoints_found = np.count_nonzero(np.ediff1d(timepoints.astype(np.int8)) > 0)
Expand Down

0 comments on commit bb48dd9

Please sign in to comment.