-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helper file to run multi-animal DLC projects with VAME
- Loading branch information
1 parent
70fb499
commit e4595e7
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Mon Feb 7 10:20:44 2022 | ||
@author: Charitha Omprakash, LIN Magdeburg, [email protected] | ||
This file converts a multi-animal DLC CSV to several single animal DLC files. | ||
Those can be used as input to run VAME. | ||
""" | ||
|
||
import pandas, numpy as pd, np | ||
import os | ||
import glob | ||
from pathlib import Path | ||
|
||
def convert_multi_csv_to_individual_csv(csv_files_path): | ||
csvs = sorted(glob.glob(os.path.join(csv_files_path, '*.csv*'))) | ||
|
||
for csv in csvs: | ||
fname = pd.read_csv(csv, header=[0,1,2], index_col=0, skiprows=1) | ||
individuals = fname.columns.get_level_values('individuals').unique() | ||
for ind in individuals: | ||
fname_temp = fname[ind] | ||
fname_temp_path = os.path.splitext(csv)[0] + '_' + ind + '.csv' | ||
fname_temp.to_csv(fname_temp_path, index=True, header=True) |