forked from barrywark/pldaps-importer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathovationimport.m
154 lines (112 loc) · 5.53 KB
/
ovationimport.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
% ===================================
% Ovation Import for PLDAPS Users
% ===================================
%
% Outline for an automated input script to get the PDS and plx
% files from an experiment into Ovation. At the end of an experiment a user
% will want to import the data.
%% Connect to the database
connectionfile = '/Users/jacobyates/ovation_databases/local/nhb_rig1_jnk/rig1_test.connection';
user = 'jacob';
context = NewDataContext(connectionfile, user);
% Get a list of all projects in the context
projects = context.getProjects();
% or we can get the projects that have the right name
projects = context.getProjects('LIP target encoding');
project = projects(end);
% see notes file for adding a project
experiment = project.insertExperiment('test experiment', datetime(2012, 4, 2));
%% Put the user inputs up front so they can change what matters for the day
% Some of these will change from day to day. Some will remain constant
% throughout the course of an entire project. Lets put them at the front of
% the import script so the experimenter can easily change inputs.
% Which files are being imported -- there will usually be multiple pds
% files from a day and multiple plx files. The experimentor will convert
% all plx files into matlab friendly versions before running this script.
% Mapping
% works if you're in the ovation-pldaps-importer/ directory
user.map_pdsfile = './Data/jlyTest040212tmpsaccademapping1102.PDS';
user.map_plxmatfile = './Data/jlyTest040212tmpSaccadeMapping1103.mat';
user.map_plxfile = './Data/jlyTest040212tmpSaccadeMapping1103.plx';
user.dots_pdsfile = './Data/jlyTest040212tmpdots1109.PDS';
user.dots_plxmatfile = './Data/jlyTest040212tmpDots1103.mat';
user.dots_plxfile = './Data/jlyTest040212tmpDots1103.plx';
% Some sort of qualitative flag for how the experiment went
user.quality = 'test'; % ('bad') 'good'
% User specifies how many cells there were
user.numbercells = 3;
% User specifies the [channel unit] position for each good unit
user.goodpos = [3 2; 3 3; 4 2];
% sources that change daily -- the location in the grid
user.gridlocations = {'L3P0', 'L1P2'};
user.timezone = 'America/Chicago';
% number of trials to use. This should be all trials, but for testing
% purposes, it could be set to something else.
user.ntrials = 45;
% Project level information
user.projectname = 'LIP multineuron';
user.projectdescription = 'Detailed multi-neuron coding of decisions in parietal cortex';
user.username = 'jacob';
user.keywords = {'LIP', 'decision', 'temporal integration', 'GLM', 'reverse correlation'};
user.subject = 'pat';
user.chamber = {'LIP-right', 'MT-right'};
% Device information (also won't change) (I took this from the ovation code
% that barry wrote)
devices.psychToolbox = experiment.externalDevice('PsychToolbox', 'Huk lab');
devices.psychToolbox.addProperty('psychtoolbox version', '3.0.8');
devices.psychToolbox.addProperty('matlab version', 'R2009a 32bit');
devices.datapixx = experiment.externalDevice('DataPixx', 'VPixx Technologies');
devices.monitor = experiment.externalDevice('Monitor LH 1080p', 'LG');
devices.monitor.addProperty('resolution', NumericData([1920, 1080]));
devices.eye_tracker = experiment.externalDevice('Eye Trac 6000', 'ASL');
devices.eye_tracker_timer = experiment.externalDevice('Windows', 'Microsoft');
%% this creates a local database -- it won't be in the final script
% ovation.util.createLocalOvationDatabase('ovation', ...
% 'ovation_test',...
% 'jacob',...
% 'password',...
% '/opt/object/mac86_64/oolicense.txt',...
% 'UT::Huk');
%% Connecting to the Ovation database
% ==================================
% Connect to the newly created database as the username "jacob"
% (password: password) by calling the ovation.NewDataContext function.
% Enter "password" (no quotes) when prompted for a password.
databasepath = 'gotta make a database';
context = ovation.NewDataContext(databasepath, 'jacob');
% This function returns a DataContext object which acts as a workspace for
% interacting with objects from the database.
%% Adding to the database
% ======================
%
%% 1) check if project exists? add it if it doesn't?
% get the projects that have the right name
projects = context.getProjects(user.projectname);
%% 2) add an experiment
% the experiment structure is at the level below projects. In our case,
% each day is probably one experiment.
experiment = project.insertExperiment('experiment name', datetime(2012, 2, 2));
% Experiments have sources. Sources are where the data comes from. In this
% case, the sources can be the subject, a chamber, a grid location, etc.
%TODO: use sourceForInsertion
pat = context.insertSource('monkey');
pat.addProperty('name', user.subject);
% i specified multiple possible chambers and multiple grid locations above.
% I don't know the best way to handle that here
LIPright = pat.insertSource(user.chamber{i});
src = LIPright.insertSource(user.gridlocations{i});
%% 3) adding the epoch groups
% epoch groups are the set of trials contained by one file. One epoch group
% will have a set of epochs (trials). Each epoch group should, in our case,
% have a PDS file and a plx.mat file to go with it
% import for all pds files specified (mapping, decision, etc.)
% Import PDS
epochGroup = ImportPladpsPDS(experiment,...
src,...
user.pdsfile,...
user.timezone, user.ntrials);
% Import PLX
ImportPLX(epochGroup,...
user.plxmatfile, ...
user.plxfile, ...
user.ntrials);