-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnr_import_from_ipad.m~
49 lines (35 loc) · 1.56 KB
/
nr_import_from_ipad.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
function [json_mat_conv_file] = nr_import_from_ipad(json_filename,json_mat_conv_dir)
%% Rich Stoner, 2011
% import json file from responseApp ipad app into matlab
% clear all
% clc
% set this filename
% json_filename = 'Rich.stoner-exp-2011-09-13-14-52-32.json';
% [json_filename, json_dir] =uigetfile('*.json','Ipad files (*.json)'); % choose abf file from CD or proper directory
if ~isempty(strfind(json_filename,'ps'))
json_filename_ps = strfind(json_filename,'ps')
sbj = json_filename(json_filename_ps(1):json_filename_ps(1)+9);
elseif ~isempty(strfind(json_filename,'ec'))
json_filename_ec = strfind(json_filename,'ec')
sbj = json_filename(json_filename_ec(1):json_filename_ec(1)+9);
end
json_filename_slash = strfind(json_filename,'/')
find_dir = json_filename_slash(end)
json_mat_conv_file = [sbj,'_jsn_',json_filename(find_dir:end)]; %%use 47:57 for jsn_l or jsn_r
json_str = fileread(json_filename);
json_filename = '~/Dropbox/cluster_files/data/ps_et_0025/jsn_l/ps_et_0025_03_Lecog_ipad_prelead.json'
% parsed using third party library
[dataset] = nr_parse_json(json_str);
array_list = dataset{1,1};
% distribute into individual arrays
description = {}; % cell array
timestamp = []; % standard array of doubles
for i = 1:length(array_list)
% uncomment to display
% disp(sprintf('%s\t%s ms', array_list{1,i}{1,1}, array_list{1,i}{1,2}));
description{i} = array_list{1,i}{1,1};
timestamp(i) = str2double(array_list{1,i}{1,2});
end
%cd([json_dir(1:end-5),'anl'])
cd(json_mat_conv_dir)
save(json_mat_conv_file, 'description','timestamp')