# Path: pyglm/utils/io.py
# def segment_data(data, (T_start, T_stop)):
#     """ Extract a segment of the data
#     """
#     import copy
#     new_data = copy.deepcopy(data)
#     
#     # Check that T_start and T_stop are within the range of the data
#     assert T_start >= 0 and T_start <= data['T']
#     assert T_stop >= 0 and T_stop <= data['T']
#     assert T_start < T_stop
# 
#     # Set the new T's
#     new_data['T'] = T_stop - T_start
# 
#     # Get indices for start and stop of spike train
#     i_start = T_start // data['dt']
#     i_stop = T_stop // data['dt']
#     new_data['S'] = new_data['S'][i_start:i_stop, :]
#     
#     # Get indices for start and stop of stim
#     i_start = T_start // data['dt_stim']
#     i_stop = T_stop // data['dt_stim']
#     new_data['stim'] = new_data['stim'][i_start:i_stop, :]
#     
#     return new_data


import cPickle
import os
from pyglm.utils.io import segment_data



data_dir = '/Users/scott/Projects/pyglm/data/synth/dist/N16T300/2014_07_22-10_01/'

with open(os.path.join(data_dir, 'data.pkl')) as f:
    data = cPickle.load(f)
  

data_test = segment_data(data, (240,300))
with open(os.path.join(data_dir, 'data_test.pkl'), 'w') as f:
    cPickle.dump(data_test, f, protocol=-1)

ts = [15,30,60,120,180, 240]
datas = []

data_test
for t in ts:

# Path: pyglm/utils/io.py
# def segment_data(data, (T_start, T_stop)):
#     """ Extract a segment of the data
#     """
#     import copy
#     new_data = copy.deepcopy(data)
#     
#     # Check that T_start and T_stop are within the range of the data
#     assert T_start >= 0 and T_start <= data['T']
#     assert T_stop >= 0 and T_stop <= data['T']
#     assert T_start < T_stop
# 
#     # Set the new T's
#     new_data['T'] = T_stop - T_start
# 
#     # Get indices for start and stop of spike train
#     i_start = T_start // data['dt']
#     i_stop = T_stop // data['dt']
#     new_data['S'] = new_data['S'][i_start:i_stop, :]
#     
#     # Get indices for start and stop of stim
#     i_start = T_start // data['dt_stim']
#     i_stop = T_stop // data['dt_stim']
#     new_data['stim'] = new_data['stim'][i_start:i_stop, :]
#     
#     return new_data


# Path: scripts/split_data.py
import cPickle
import os
from pyglm.utils.io import segment_data




data_dir = '/Users/scott/Projects/pyglm/data/synth/dist/N16T300/2014_07_22-10_01/'

with open(os.path.join(data_dir, 'data.pkl')) as f:
    data = cPickle.load(f)
  

data_test = segment_data(data, (240,300))
with open(os.path.join(data_dir, 'data_test.pkl'), 'w') as f:
    cPickle.dump(data_test, f, protocol=-1)

ts = [15,30,60,120,180, 240]
datas = []

data_test
for t in ts:

    datas.append(segment_data(data, (0,t)))