Skip to content

Commit

Permalink
Add read zarr
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhixiaoSu committed Jul 30, 2024
1 parent fa801d5 commit 71befc8
Show file tree
Hide file tree
Showing 467 changed files with 7,896 additions and 7 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies = [
'pathlib',
'numpy',
'pydantic'
'hdmf_zarr'
]

[project.optional-dependencies]
Expand Down
19 changes: 14 additions & 5 deletions src/aind_dynamic_foraging_basic_analysis/lick_analysis.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
"""Load packages."""
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from aind_ephys_utils import align
from pynwb import NWBHDF5IO
from hdmf_zarr import NWBZarrIO
from scipy.stats import norm


def load_nwb(nwb_file):
"""Load NWB file."""
io = NWBHDF5IO(nwb_file, mode="r")
nwb = io.read()
return nwb
if os.path.isdir(nwb_file):
io = NWBZarrIO(nwb_file, mode="r")
nwb = io.read()
return nwb
elif os.path.isfile(nwb_file):
io = NWBHDF5IO(nwb_file, mode="r")
nwb = io.read()
return nwb
else:
print("nwb file does not exist.")
return None


def plot_lick_analysis(nwb):
Expand Down Expand Up @@ -290,7 +300,7 @@ def cal_metrics(data):
ref_kernel = np.convolve(ref, kernel)
finish_kernel = np.convolve(finish.astype(float), kernel)
finish_kernel = np.divide(finish_kernel, ref_kernel)
finish_kernel = finish_kernel[int(0.5 * len(kernel)):-int(0.5 * len(kernel))]
finish_kernel = finish_kernel[int(0.5 * len(kernel)): -int(0.5 * len(kernel))]
all_go_no_rwd = tbl_trials.loc[
(tbl_trials["animal_response"] != 2)
& (tbl_trials["rewarded_historyL"] == 0)
Expand Down Expand Up @@ -562,7 +572,6 @@ def plot_raster_rate(

# example use
if __name__ == "__main__":
import os
from pathlib import Path

"""Example."""
Expand Down
Binary file modified tests/data/689514_2024-02-01_18-06-43qc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/data/705599_2024-05-31_14-06-54.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/data/705599_2024-05-31_14-06-54qc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/data/717121_2024-06-15_10-58-01.nwb/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
".specloc": "specifications",
"namespace": "core",
"neurodata_type": "NWBFile",
"nwb_version": "2.7.0",
"object_id": "8a55d854-abb9-4f41-9bb9-933acd94885c"
}
3 changes: 3 additions & 0 deletions tests/data/717121_2024-06-15_10-58-01.nwb/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"zarr_format": 2
}
Loading

0 comments on commit 71befc8

Please sign in to comment.