Skip to content

Commit 609dfc3

Browse files
committed
2 parents 716fd4c + 5d60bb5 commit 609dfc3

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

lecilab_behavior_analysis/df_transforms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def add_port_where_animal_comes_from(df_in: pd.DataFrame) -> pd.DataFrame:
121121
# equal to the original dataframe
122122
df.loc[df_mouse_session.index, 'roa_choice'] = series_to_append
123123
# add also the port where the animal comes from
124-
df.loc[df_mouse_session.index, 'previous_port_before_stimulus'] = last_choice
124+
last_choice_series = pd.Series(last_choice, index=df_mouse_session.index)
125+
df.loc[df_mouse_session.index, 'previous_port_before_stimulus'] = last_choice_series.astype("string")
126+
125127

126128
return df
127129

lecilab_behavior_analysis/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def get_outpath():
317317
"lorena-ThinkPad-E550": "/home/emma/Desktop/EloiJacomet/data",
318318
"tectum": "/mnt/c/Users/HMARTINEZ/LeCiLab/data/behavioral_data",
319319
"tudou": "/home/kudongdong/data/LeciLab/behavioral_data",
320-
"nuo-rostower": "/home/kudongdong/Documents/data/LeciLab/behavioral_data",
320+
"nuo-rostower": "/home/nuo/Documents/data/LeciLab/behavioral_data",
321321
"minibaps": "/archive/training_village",
322322
}
323323
return paths.get(hostname, "default/path")
@@ -408,6 +408,12 @@ def rsync_specific_file(
408408
"""
409409
This method syncs the session data from the server to the local machine.
410410
"""
411+
if not os.path.isdir(local_path):
412+
try:
413+
os.makedirs(local_path) # Creates the directory (and parents if needed)
414+
print(f"Directory '{local_path}' created.")
415+
except OSError as e:
416+
print(f"Error creating directory '{local_path}': {e}")
411417
remote_path = f"{credentials['username']}@{credentials['host']}:{file_path}"
412418
rsync_command = f"rsync -avz {remote_path} {local_path}"
413419
result = subprocess.run(rsync_command, shell=True)
@@ -1109,7 +1115,10 @@ def get_previous_row_index(df: pd.DataFrame, current_index) -> int:
11091115
raise IndexError("No previous row exists for the given index.")
11101116

11111117

1112-
def transform_side_choice_to_numeric(side: str) -> Union[int, float]:
1118+
def transform_side_choice_to_numeric(side) -> Union[int, float]:
1119+
if pd.isna(side):
1120+
return np.nan
1121+
11131122
match side:
11141123
case "left":
11151124
return 1

0 commit comments

Comments
 (0)