The loren_frank_data_processing
package imports Matlab data processed by Loren Frank's lab into a friendly python format using pandas.
In order to use, the data must follow the format proscribed in this wiki.
Features
- Takes advantages of pandas
DataFrame
, a expressive labeled data format, and associated data manipulation and alignment tools. - Time is encoded as pandas
Timedelta
, which avoids funny business with representing time series as floating points. - Handy utility for reshaping time series relative to events of interest (
reshape_to_segments
)
pip install loren_frank_data_processing
OR
conda install -c edeno loren_frank_data_processing
loren_frank_data_processing
requires:
- python>=3.5
- numpy
- scipy
- pandas
- xarray (only if using features from the saving module)
- netcdf4 (only if using features from the saving module)
See environment.yml for the most current list of dependencies.
- Find all recording epochs:
from collections import namedtuple
from os.path import join
from loren_frank_data_processing import make_epochs_dataframe
ROOT_DIR = 'example/path'
RAW_DATA_DIR = join(ROOT_DIR, 'Raw-Data')
Animal = namedtuple('Animal', {'directory', 'short_name'})
ANIMALS = {
'HPa': Animal(directory=join(RAW_DATA_DIR, 'HPa_direct'),
short_name='HPa'),
}
epoch_info = make_epochs_dataframe(ANIMALS)
epoch_info
- We can filter by epoch type:
epoch_info.loc[epoch_info.type == 'run']
- We can use the
epoch_info
index to access the tetrode information for a recording session.
epoch_info.loc[epoch_info.type == 'run'].index.tolist()
Out:
[('HPa', 1, 2),
('HPa', 1, 4),
('HPa', 1, 6),
('HPa', 2, 2),
('HPa', 2, 4),
('HPa', 3, 2),
('HPa', 3, 4),
('HPa', 4, 2),
('HPa', 4, 4),
('HPa', 5, 2),
('HPa', 5, 4),
('HPa', 6, 2),
('HPa', 6, 4),
('HPa', 7, 2),
('HPa', 7, 4),
('HPa', 8, 2),
('HPa', 8, 4)]
from loren_frank_data_processing import make_tetrode_dataframe
epoch_key = ('HPa', 1, 2)
tetrode_info = make_tetrode_dataframe(ANIMALS)
tetrode_info.xs(epoch_key, drop_level=False)
Similarly, the index for the tetrode info can be used as a key to access LFP information