forked from ackman678/wholeBrainDX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdxInputParamsSetup.m
More file actions
86 lines (78 loc) · 3.01 KB
/
Copy pathdxInputParamsSetup.m
File metadata and controls
86 lines (78 loc) · 3.01 KB
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
function [region, def] = dxInputParamsSetup(region, def)
%dxInputParamsSetup
%Examples:
% >>region = dxInputParamsSetup(region)
%USE:
% region -- region data structure returned from calciumdx
%(Optional: For the 'extraFiles' variable that will be assigned to region.extraFiles **pass filenames for additional tiff movie files** ('region.extraFiles') if the recording consists of multiple 2GB tiff files) as a **space-delimited character vector**. This will be passed downstream using textscan()
%nframes: Set to the number of frames so that the motor signal preprocessing is the correct length
%James B. Ackman 2014-02-23 15:39:17, 2014-12-30 15:44:40
prompt = {'Spatial resolution (um/px):','Temporal resolution (sec):', 'Number of movie frames:' ,'extraFiles:'};
dlg_title = 'Input experimental parameters';
num_lines = 1;
if nargin < 2 || isempty(def)
if isfield(region,'spaceres') & isfield(region,'timeres') & isfield(region,'nframes') & isfield(region,'extraFiles')
def = {num2str(region.spaceres),num2str(region.timeres),num2str(region.nframes),region.extraFiles};
else
def = {'','','3000',''};
end
end
optionsDlg.Resize='on';
answer = inputdlg(prompt,dlg_title,num_lines,def,optionsDlg);
if ~isfield(region,'image')
[filename, pathname] = uigetfile({'*.jpg;*.png;*.tif'}, 'Choose AVG single frame image file to open');
fn = fullfile(pathname,filename);
img = imread(fn);
region.image = img;
elseif isempty(region.image)
[filename, pathname] = uigetfile({'*.jpg;*.png;*.tif'}, 'Choose AVG single frame image file to open');
fn = fullfile(pathname,filename);
img = imread(fn);
region.image = img;
end
def = answer;
region.spaceres = str2double(answer{1});
region.timeres = str2double(answer{2});
region.nframes = str2double(answer{3});
region.extraFiles = answer{4};
if ~isfield(region,'name') & ~isfield(region,'coords')
region.name{1} = 'field';
sz = size(region.image);
region.coords{1} = [1 1; 1 sz(1); sz(2) sz(1); sz(2) 1];
elseif isempty(region.name)
region.name{1} = 'field';
sz = size(region.image);
region.coords{1} = [1 1; 1 sz(1); sz(2) sz(1); sz(2) 1];
end
if ~isfield(region,'stimuli')
region.stimuli = [];
end
if ~isfield(region,'motorSignal')
region.motorSignal = [];
end
if ~isfield(region,'orientation')
imgfig = figure; imagesc(region.image)
[x y butt] = ginput(1);
x = round(x);
y = round(y);
if x < 0
x = 0;
elseif x > size(region.image,2)
x = size(region.image,2);
end
if y < 0
y = 0;
elseif y > size(region.image,1)
y = size(region.image,1);
end
def_ans1 = 'anteriormedial point = (Y,X); (Y,X) = row, cols';
def_ans2 = [y x];
prompt = {'Provide description of orientation coordinate in image:','orientation coordinate in image [Y]:', 'orientation coordinate in image [X]:'};
dlg_title = 'Input experimental parameters';
num_lines = 1;
def2 = {def_ans1,num2str(def_ans2(1)),num2str(def_ans2(2))};
answer = inputdlg(prompt,dlg_title,num_lines,def2);
region.orientation.description = answer{1};
region.orientation.value = [str2double(answer{2}) str2double(answer{3})];
close(imgfig)
end