-
Notifications
You must be signed in to change notification settings - Fork 0
/
split_cycle.py
34 lines (27 loc) · 1.6 KB
/
split_cycle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pandas as pd
import numpy as np
import os
from foldometer.tools.region_manipulation import get_cycle_region_by_cycle_previous_retracting_and_next_early_retracting, get_cycle_region_time_sorted
from analysis_functionality.tools.str_analysis import int_to_000str
folderProject = "D:/projects/Rubisco"
def split_cycle(folderProject=folderProject):
folderData = folderProject + "/" + "wlc_manual_fit"
folderSave = folderProject + "/" + "split_cycle"
if not os.path.exists(folderSave):
os.mkdir(folderSave)
names = [name[:-4] for name in os.listdir(folderData)]
for name in names:
data = pd.read_csv(folderData+"/"+name+".csv")
for index,cycle in enumerate(get_cycle_region_by_cycle_previous_retracting_and_next_early_retracting(data)):
(pullingCycleRetracting, regionRetracting, maskRetracting) = cycle['retracting']
(pullingCycleStationary, regionStationary, maskStationary) = cycle['stationary']
(pullingCyclePulling, regionPulling, maskPulling) = cycle['pulling']
(pullingCycleNextRetracting, regionNextRetracting, maskNextRetracting) = cycle['nextRetracting']
data["region"].loc[maskRetracting] = 'retracting'
data["region"].loc[maskStationary] = 'stationary'
data["region"].loc[maskPulling] = 'pulling'
data["region"].loc[maskNextRetracting] = 'nextRetracting'
mask = maskRetracting + maskStationary + maskPulling + maskNextRetracting
data.loc[mask].to_csv(folderSave+"/"+name+"-c"+int_to_000str(index)+".csv")
if __name__ == '__main__':
split_cycle()