Skip to content

Commit

Permalink
netCDF4
Browse files Browse the repository at this point in the history
  • Loading branch information
luiztauffer committed Nov 21, 2024
1 parent 678aad5 commit f5daf2c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ imageio==2.34.1
imageio-ffmpeg==0.5.1
pynwb==2.8.1
tables>=3.10.0
movement==0.0.20
movement==0.0.20
netCDF4>=1.7.2
30 changes: 21 additions & 9 deletions src/vame/analysis/generative_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ def generative_model(

if mode == "sampling":
latent_vector = np.load(
os.path.join(path_to_file, "latent_vector_" + session + ".npy")
os.path.join(
path_to_file,
"latent_vector_" + session + ".npy",
)
)
return random_generative_samples(
cfg,
Expand All @@ -291,7 +294,10 @@ def generative_model(

if mode == "reconstruction":
latent_vector = np.load(
os.path.join(path_to_file, "latent_vector_" + session + ".npy")
os.path.join(
path_to_file,
"latent_vector_" + session + ".npy",
)
)
return random_reconstruction_samples(
cfg,
Expand All @@ -305,7 +311,10 @@ def generative_model(
f"Algorithm {segmentation_algorithm} not supported for cluster center visualization."
)
cluster_center = np.load(
os.path.join(path_to_file, "cluster_center_" + session + ".npy")
os.path.join(
path_to_file,
"cluster_center_" + session + ".npy",
)
)
return visualize_cluster_center(
cfg,
Expand All @@ -315,7 +324,10 @@ def generative_model(

if mode == "motifs":
latent_vector = np.load(
os.path.join(path_to_file, "latent_vector_" + session + ".npy")
os.path.join(
path_to_file,
"latent_vector_" + session + ".npy",
)
)
labels = np.load(
os.path.join(
Expand All @@ -330,11 +342,11 @@ def generative_model(
)
)
return random_generative_samples_motif(
cfg,
model,
latent_vector,
labels,
n_clusters,
cfg=cfg,
model=model,
latent_vector=latent_vector,
labels=labels,
n_clusters=n_clusters,
)
except Exception as e:
logger.exception(str(e))
Expand Down
2 changes: 1 addition & 1 deletion src/vame/io/load_poses.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ def load_vame_dataset(ds_path: Path | str) -> xr.Dataset:
Returns:
--------
"""
return xr.open_dataset(ds_path)
return xr.open_dataset(ds_path, engine="netcdf4")
28 changes: 16 additions & 12 deletions src/vame/util/align_egocentrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ def align_mouse(
i = interpol_first_rows_nans(i)

if use_video:
video_path = str(os.path.join(
project_path,
"data",
"raw",
session + video_format,
))
video_path = str(
os.path.join(
project_path,
"data",
"raw",
session + video_format,
)
)
capture = cv.VideoCapture(video_path)
if not capture.isOpened():
raise Exception(f"Unable to open video file: {video_path}")
Expand Down Expand Up @@ -304,12 +306,14 @@ def alignment(

if use_video:
# compute background
video_path = str(os.path.join(
project_path,
"data",
"raw",
session + video_format,
))
video_path = str(
os.path.join(
project_path,
"data",
"raw",
session + video_format,
)
)
bg = background(
project_path=project_path,
session=session,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,16 @@ def test_gif_frames_files_exists(setup_project_and_evaluate_model, label):
vame.segment_session(setup_project_and_evaluate_model["config_path"])

def mock_background(
path_to_file=None,
filename=None,
project_path=None,
session=None,
video_path=None,
num_frames=None,
save_background=True,
):
num_frames = 100
return background(
project_path=path_to_file,
session=filename,
project_path=project_path,
session=session,
video_path=video_path,
num_frames=num_frames,
save_background=save_background,
Expand Down

0 comments on commit f5daf2c

Please sign in to comment.