Skip to content

Commit

Permalink
Change split filename method for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Atika-Syeda committed Jan 10, 2023
1 parent 42f5442 commit a7f193d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
8 changes: 6 additions & 2 deletions facemap/gui/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,12 @@ def save_cluster_video(self, parent, fps, num_frames_gif):
cumframes, Ly, Lx, capture = utils.get_frame_details(parent.filenames)
capture = capture[0][0]
num_clusters = len(np.unique(self.cluster_labels))
filename, ext = parent.filenames[0][0].split(".")
filename = filename.split("/")[-1] # Use video filename
filename, ext = os.path.splitext(
parent.filenames[0][0]
) # parent.filenames[0][0].split(".")
filename = os.path.basename(
filename
) # filename.split("/")[-1] # Use video filename

# Create 2D list of random frames selected from each cluster
cluster_frames_2D_list = np.zeros((num_clusters, num_frames_gif))
Expand Down
3 changes: 2 additions & 1 deletion facemap/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import pyqtgraph as pg
import scipy.io as sio
from pathlib import Path
from matplotlib import cm
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QFont, QIcon, QPainterPath
Expand Down Expand Up @@ -793,7 +794,7 @@ def update_pose_model_combo_box(self):
models = model_loader.get_model_states_paths()
models.append(model_loader.get_basemodel_state_path())
for m in models:
model_name = m.split("/")[-1].split(".")[0]
model_name = Path(m).stem # m.split("/")[-1].split(".")[0]
if model_name == "facemap_model_state":
continue
self.pose_model_combobox.addItem(model_name)
Expand Down
10 changes: 7 additions & 3 deletions facemap/gui/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def open_proc(parent, file_name=None):
if "pupil_sigma" in roi:
psig = roi["pupil_sigma"]
parent.pupil_sigma = psig
parent.sigmaBox.setText(str(roi["pupil_sigma"]))
parent.sigma_box.setText(str(roi["pupil_sigma"]))
else:
psig = None
parent.ROIs.append(
Expand Down Expand Up @@ -484,8 +484,12 @@ def load_trace_data(parent):


def save_clustering_output(output, parent):
filename, ext = parent.filenames[0][0].split(".")
filename = filename.split("/")[-1] # Use video filename
filename, ext = os.path.splitext(
parent.filenames[0][0]
) # parent.filenames[0][0].split(".")
filename = os.path.basename(
filename
) # filename.split("/")[-1] # Use video filename
savename = os.path.join(parent.save_path, ("%s_facemap_clusters.npy" % filename))
np.save(savename, output)
parent.update_status_bar("Clustering output saved: " + savename)
Binary file modified facemap/gui/ops_user.npy
Binary file not shown.
13 changes: 8 additions & 5 deletions tests/test_svd_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from facemap import process

r_tol, a_tol = 1, 1 #1e-2, 1
r_tol, a_tol = 1, 1 # 1e-2, 1


def test_output_single_video(data_dir, video_names, expected_output_dir):
Expand Down Expand Up @@ -113,16 +113,19 @@ def check_frames(test_output, expected_output):

def check_U(test_output, expected_output):
motionMask = np.allclose(
test_output["motMask"][0], expected_output["motMask"][0], rtol=r_tol+5, atol=a_tol+5
test_output["motMask"][0],
expected_output["motMask"][0],
rtol=r_tol + 5,
atol=a_tol + 5,
)
movieMask = np.allclose(
test_output["movMask"][0], expected_output["movMask"][0], rtol=r_tol, atol=a_tol
)
motionMask_reshape = np.allclose(
test_output["motMask_reshape"][0],
expected_output["motMask_reshape"][0],
rtol=r_tol+5,
atol=a_tol+5,
rtol=r_tol + 5,
atol=a_tol + 5,
)
movMask_reshape = np.allclose(
test_output["movMask_reshape"][0],
Expand All @@ -133,7 +136,7 @@ def check_U(test_output, expected_output):
print("motionMask", motionMask)
print("movieMask", movieMask)
print("motionMask_reshape", motionMask_reshape)
print("movMask_reshape", movMask_reshape)
print("movMask_reshape", movMask_reshape)
return motionMask and movieMask and motionMask_reshape and movMask_reshape


Expand Down

0 comments on commit a7f193d

Please sign in to comment.