In [1]:
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set_context('paper')
sns.set_style('ticks')
In [2]:
import numpy as np
import pandas as pd
from glob import glob
from os.path import join, exists
from os import remove
import json
In [3]:
directory = '/tier2/freeman/Nick/lfov.calibration'
In [4]:
key = '2016-04-23'
name = 'anm-0330549-5'
In [12]:
drop = {'trials': range(323, 500)} #range(0,31)
In [5]:
path = join(directory, 'reprocessed', name, key, 'covariates')
print exists(path)
In [6]:
covariates = pd.read_csv(join(path, 'covariates.csv'))
Save list of dropped trials
In [13]:
with open(join(path, 'drop.json'), 'w') as outfile:
json.dump(drop, outfile, indent=2)
In [14]:
keep = np.ones(len(covariates), dtype='bool')
for trial in drop['trials']:
keep[(covariates.number == trial).values] = False
In [15]:
delete = covariates.index[~keep]
covariates = covariates[keep]
In [16]:
covariates.to_csv(join(path, 'covariates.csv'))
In [17]:
imagepath = join(directory, 'reprocessed', name, key, 'images')
print exists(imagepath)
In [18]:
for index in delete:
remove(join(imagepath, 'image-%05d.bin' % index))
In [19]:
summarypath = join(directory, 'reprocessed', name, key, 'summary')
with open(join(summarypath, 'meta.json')) as infile:
meta = json.load(infile)
meta['shape'] = [len(covariates)] + meta['shape'][1:]
In [20]:
with open(join(summarypath, 'meta.json'), 'w') as outfile:
json.dump(meta, outfile, indent=2)
In [ ]: