Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
edeno committed Nov 27, 2017
2 parents d07a270 + 8ff7705 commit 53c7256
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions loren_frank_data_processing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# flake8: noqa
from .core import Animal
from .multiunit import (get_multiunit_dataframe,
get_multiunit_indicator_dataframe)
from .neurons import (get_spike_indicator_dataframe, get_spikes_dataframe,
Expand Down
10 changes: 5 additions & 5 deletions loren_frank_data_processing/core.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
'''Functions for accessing data in the Frank lab format and saving
'''

from collections import namedtuple
from logging import getLogger
from os.path import join
from sys import exit

import numpy as np
import pandas as pd
from scipy.io import loadmat

logger = getLogger(__name__)

Animal = namedtuple('Animal', {'directory', 'short_name'})


def get_data_filename(animal, day, file_type):
'''Returns the Matlab file name assuming it is in the Raw Data
Expand Down Expand Up @@ -72,7 +73,7 @@ def get_epochs(animal, day):
get_data_filename(animal, day, 'task'))
return [(animal, day, ind + 1)
for ind, epoch in enumerate(task_file['task'][0, -1][0])]
except IOError as err:
except (IOError, TypeError) as err:
logger.error('Failed to load file {0}'.format(
get_data_filename(animal, day, 'task')))
exit()
Expand Down Expand Up @@ -102,10 +103,9 @@ def get_data_structure(animal, day, file_type, variable):
'''
try:
file = loadmat(get_data_filename(animal, day, file_type))
except IOError:
except (IOError, TypeError):
logger.error('Failed to load file: {0}'.format(
get_data_filename(animal, day, file_type)))
exit()
n_epochs = file[variable][0, -1].size
return [file[variable][0, -1][0, ind]
for ind in np.arange(n_epochs)]
Expand Down
7 changes: 4 additions & 3 deletions loren_frank_data_processing/tetrodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as pd
from scipy.io import loadmat

from .core import _convert_to_dict, reconstruct_time
from .core import _convert_to_dict, reconstruct_time, logger


def get_tetrode_info_path(animal):
Expand Down Expand Up @@ -53,8 +53,9 @@ def get_LFP_dataframe(tetrode_key, animals):
data=lfp_data['data'][0, 0].squeeze(),
index=lfp_time,
name='electric_potential')
except FileNotFoundError:
pass
except (FileNotFoundError, TypeError):
logger.error('Failed to load file: {0}'.format(
get_LFP_filename(tetrode_key, animals)))


def make_tetrode_dataframe(animals):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='loren_frank_data_processing',
version='0.3.4.dev0',
version='0.3.5.dev0',
license='GPL-3.0',
description=('Import data from Loren Frank lab'),
author='Eric Denovellis',
Expand Down

0 comments on commit 53c7256

Please sign in to comment.