Skip to content

Commit

Permalink
Print warnings to stderr.
Browse files Browse the repository at this point in the history
  • Loading branch information
DailyDreaming authored Dec 6, 2023
1 parent ef44afc commit 73e52e7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/braingeneers/data/datasets_electrophysiology.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import warnings
import copy

# import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import numpy as np
import shutil
import h5py
Expand Down Expand Up @@ -287,11 +287,11 @@ def load_windows(metadata, exp, window_centers, window_sz, dtype=np.float16,

# Check if window is out of bounds
if window[0] < 0 or window[1] > dataset_length:
print("Window out of bounds, inserting zeros for window",window)
print("Window out of bounds, inserting zeros for window", window)
try:
data_temp = np.zeros((data_temp.shape[0],window_sz),dtype=dtype)
except Exception as e:
print(e)
print(e, file=sys.stderr)
data_temp = load_window(metadata, exp, window, dtype=dtype, channels=channels)
else:
data_temp = load_window(metadata, exp, window, dtype=dtype, channels=channels)
Expand Down Expand Up @@ -659,10 +659,10 @@ def load_stims_maxwell(uuid: str, metadata_ephys_exp: dict = None, experiment_st
return df

except FileNotFoundError:
print(f'\tThere seems to be no stim log file for this experiment! :(')
print(f'\tThere seems to be no stim log file for this experiment! :(', file=sys.stderr)
return None
except OSError:
print(f'\tThere seems to be no stim log file (on s3) for this experiment! :(')
print(f'\tThere seems to be no stim log file (on s3) for this experiment! :(', file=sys.stderr)
return None


Expand All @@ -676,7 +676,7 @@ def load_gpio_maxwell(dataset_path, fs=20000.0):
with smart_open.open(dataset_path, 'rb') as f:
with h5py.File(f, 'r') as dataset:
if 'bits' not in dataset.keys():
print('No GPIO event in the dataset!')
print('No GPIO event in the dataset!', file=sys.stderr)
return np.array([])
bits_dataset = list(dataset['bits'])
bits_dataframe = [bits_dataset[i][0] for i in range(len(bits_dataset))]
Expand Down Expand Up @@ -1230,7 +1230,7 @@ def _axion_generate_per_block_metadata(filename: str):

fid.seek(start + int(obj.length.item()), 0)
if fid.tell() != start + obj.length:
print('Unexpected Channel array length')
print('Unexpected Channel array length', file=sys.stderr)

elif obj.type == 3:
continue
Expand Down

0 comments on commit 73e52e7

Please sign in to comment.