Skip to content

Commit

Permalink
Merge pull request #93 from catalystneuro/remove_nwb_write
Browse files Browse the repository at this point in the history
Remove NWB write functions; throw error with instructions
  • Loading branch information
CodyCBakerPhD authored Mar 1, 2022
2 parents bff68d5 + c68936d commit 10ab169
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 733 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,7 @@ fabric.properties
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea/caches/build_file_checksums.ser

#Mac
.DS_Store
29 changes: 0 additions & 29 deletions roiextractors/extraction_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
HAVE_H5 = True
except ImportError:
HAVE_H5 = False

try:
import scipy.io as spio

HAVE_Scipy = True
except ImportError:
HAVE_Scipy = False

ArrayType = Union[list, np.array]
PathType = Union[str, Path]
NumpyArray = Union[np.array, np.memmap]
Expand All @@ -28,26 +26,6 @@
FloatType = Union[float, np.float]


def dict_recursive_update(base, input_):
for key, val in input_.items():
if key in base and isinstance(val, dict) and isinstance(base[key], dict):
dict_recursive_update(base[key], val)
elif key in base and isinstance(val, list) and isinstance(base[key], list):
for i, input_list_item in enumerate(val):
if len(base[key]) < i:
if isinstance(base[key][i], dict) and isinstance(
input_list_item, dict
):
dict_recursive_update(base[key][i], input_list_item)
else:
base[key][i] = input_list_item
else:
base[key].append(input_list_item)
else:
base[key] = val
return base


def _pixel_mask_extractor(image_mask_, _roi_ids):
"""An alternative data format for storage of image masks.
Returns
Expand Down Expand Up @@ -94,7 +72,6 @@ def get_video_shape(video):
num_frames, size_x, size_y = video.shape
else:
num_channels, num_frames, size_x, size_y = video.shape

return num_channels, num_frames, size_x, size_y


Expand Down Expand Up @@ -198,7 +175,6 @@ def write_to_h5_dataset_format(
if save_path.suffix == "":
# when suffix is already raw/bin/dat do not change it.
save_path = save_path.parent / (save_path.name + ".h5")

num_channels = imaging.get_num_channels()
num_frames = imaging.get_num_frames()
size_x, size_y = imaging.get_image_size()
Expand All @@ -207,12 +183,10 @@ def write_to_h5_dataset_format(
assert isinstance(file_handle, h5py.File)
else:
file_handle = h5py.File(save_path, "w")

if dtype is None:
dtype_file = imaging.get_dtype()
else:
dtype_file = dtype

dset = file_handle.create_dataset(
dataset_path, shape=(num_channels, num_frames, size_x, size_y), dtype=dtype_file
)
Expand All @@ -224,7 +198,6 @@ def write_to_h5_dataset_format(
n_bytes = np.dtype(imaging.get_dtype()).itemsize
max_size = int(chunk_mb * 1e6) # set Mb per chunk
chunk_size = max_size // (size_x * size_y * n_bytes)

# writ one channel at a time
for ch in range(num_channels):
if chunk_size is None:
Expand Down Expand Up @@ -255,7 +228,6 @@ def write_to_h5_dataset_format(
video
)
chunk_start += chunk_frames

if save_path is not None:
file_handle.close()
return save_path
Expand All @@ -274,7 +246,6 @@ def animate_func(i, imaging, im, ax):
if ax is None:
fig = plt.figure(figsize=(5, 5))
ax = fig.add_subplot(111)

im0 = imaging.get_frames(0)
im = ax.imshow(im0, interpolation="none", aspect="auto", vmin=0, vmax=1)
interval = 1 / imaging.get_sampling_frequency() * 1000
Expand Down
Loading

0 comments on commit 10ab169

Please sign in to comment.