|
15 | 15 |
|
16 | 16 |
|
17 | 17 | """ |
18 | | -import tqdm |
| 18 | +from tqdm import tqdm |
19 | 19 |
|
20 | 20 | import numpy as np |
21 | 21 | from pathlib import Path |
|
38 | 38 | from sklearn.decomposition import PCA |
39 | 39 | from sklearn.preprocessing import StandardScaler |
40 | 40 | from npyx.corr import (ccg, StarkAbeles2009_ccg_significance, ccg_sig_stack, gen_sfc, scaled_acg) |
41 | | -from npyx.gl import get_units |
| 41 | +from npyx.gl import get_units, get_npyx_memory |
42 | 42 | ############################################# |
43 | 43 | # Waveform features |
44 | 44 |
|
@@ -791,7 +791,8 @@ def previous_peak(waves, chan_path, unit, n_chans = 20): |
791 | 791 | # detect_peaks |
792 | 792 | # find most negative peak |
793 | 793 | # check if there is a peak before the most negative one |
794 | | - max_chan_path = list(Path(chan_path/'routinesMemory').glob(f'dsm_{unit}_peakchan*'))[0] |
| 794 | + dpnm = get_npyx_memory(chan_path) |
| 795 | + max_chan_path = list(dpnm.glob(f'dsm_{unit}_peakchan*'))[0] |
795 | 796 | max_chan = int(np.load(max_chan_path)) |
796 | 797 | # waves = waves.T |
797 | 798 | if max_chan <= n_chans - 1: |
@@ -932,7 +933,8 @@ def chan_spread(all_wav, chan_path, unit, n_chans = 20, chan_spread_dist = 25.6) |
932 | 933 | _,_, p2p = consecutive_peaks_amp(all_wav.T) |
933 | 934 |
|
934 | 935 | # search for the file that has the given peak chan |
935 | | - max_chan_path = list(Path(chan_path/'routinesMemory').glob(f'dsm_{unit}_peakchan*'))[0] |
| 936 | + dpnm = get_npyx_memory(chan_path) |
| 937 | + max_chan_path = list(dpnm.glob(f'dsm_{unit}_peakchan*'))[0] |
936 | 938 | max_chan = int(np.load(max_chan_path)) |
937 | 939 |
|
938 | 940 | chanmap = chan_map(chan_path) |
@@ -1326,7 +1328,8 @@ def chan_spread_bp_plot(dp, unit, n_chans=20): |
1326 | 1328 | Input: datapath and unit (drift and shift matched datasets for now) |
1327 | 1329 | Returns: plot |
1328 | 1330 | """ |
1329 | | - curr_fil = dp/'routinesMemory'/f'dsm_{unit}_all_waves_100-82_regular_False300-FalseNone-FalseNone.npy' |
| 1331 | + dpnm = get_npyx_memory(dp) |
| 1332 | + curr_fil = dpnm/f'dsm_{unit}_all_waves_100-82_regular_False300-FalseNone-FalseNone.npy' |
1330 | 1333 | if curr_fil.is_file(): |
1331 | 1334 |
|
1332 | 1335 | if n_chans %2 !=0: n_chans +=1 |
@@ -1529,7 +1532,8 @@ def gen_ss_cs(recs_fn, show = False): |
1529 | 1532 |
|
1530 | 1533 | # dp = "/media/npyx/ssd2/ago/optotag/recordings/PkC/18-08-30_YC001_probe1" |
1531 | 1534 | # create the main folder for the images to be saved |
1532 | | - ss_cs_folder = Path(ds['dp']+'/routinesMemory/ss_cs') |
| 1535 | + dpnm = get_npyx_memory(dp) |
| 1536 | + ss_cs_folder = dpnm / 'ss_cs' |
1533 | 1537 | ss_cs_folder.mkdir(exist_ok=True, parents=True) |
1534 | 1538 |
|
1535 | 1539 | #%% Find CCGs with long pause (at least 5ms) |
@@ -1598,7 +1602,7 @@ def process_all(recs_fn, show = False, again = False): |
1598 | 1602 | all_feat = [] |
1599 | 1603 | for i, ds in list(recs.items())[:]: |
1600 | 1604 | print(f"/nProcessing dataset {ds['dp']}...") |
1601 | | - data_root = Path(ds['dp'])/'routinesMemory' |
| 1605 | + data_root = get_npyx_memory(ds['dp']) |
1602 | 1606 | features_folder = data_root / 'features' |
1603 | 1607 | acg_folder = data_root / 'acg' |
1604 | 1608 | wvf_folder = data_root / 'wvf' |
@@ -1688,7 +1692,7 @@ def process_all(recs_fn, show = False, again = False): |
1688 | 1692 | print("Computing PCA features across datasets...") |
1689 | 1693 | for i, ds in list(recs.items())[:]: |
1690 | 1694 | # data_root = Path('/home/npyx/projects/optotag/proc_data') |
1691 | | - data_root = Path(ds['dp'])/'routinesMemory' |
| 1695 | + data_root = get_npyx_memory(ds['dp']) |
1692 | 1696 | features_folder = data_root / 'features' |
1693 | 1697 | acg_folder = data_root / 'acg' |
1694 | 1698 | wvf_folder = data_root / 'wvf' |
@@ -1799,7 +1803,7 @@ def process_all(recs_fn, show = False, again = False): |
1799 | 1803 |
|
1800 | 1804 | for i, ds in list(recs.items())[:]: |
1801 | 1805 | # data_root = Path('/home/npyx/projects/optotag/proc_data') |
1802 | | - data_root = Path(ds['dp'])/'routinesMemory' |
| 1806 | + data_root = get_npyx_memory(ds['dp']) |
1803 | 1807 | features_folder = data_root / 'features' |
1804 | 1808 | acg_folder = data_root / 'acg' |
1805 | 1809 | wvf_folder = data_root / 'wvf' |
@@ -1859,7 +1863,7 @@ def process_all(recs_fn, show = False, again = False): |
1859 | 1863 |
|
1860 | 1864 | for i, ds in list(recs.items())[:]: |
1861 | 1865 | # data_root = Path('/home/npyx/projects/optotag/proc_data') |
1862 | | - data_root = Path(ds['dp'])/'routinesMemory' |
| 1866 | + data_root = get_npyx_memory(ds['dp']) |
1863 | 1867 | features_folder = data_root / 'features' |
1864 | 1868 | acg_folder = data_root / 'acg' |
1865 | 1869 | wvf_folder = data_root / 'wvf' |
|
0 commit comments