0001 function GND=avgs2GND_nobase(gui_infiles_or_tmplt,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125 p=inputParser;
0126 p.addRequired('gui_infiles_or_tmplt',@(x) ischar(x) || iscell(x));
0127 p.addParamValue('locfile',[],@ischar);
0128 p.addParamValue('sub_ids',[],@isnumeric);
0129 p.addParamValue('bsln',[],@(x) isnumeric(x) && length(x)==2);
0130 p.addParamValue('use_bins',[],@isnumeric);
0131 p.addParamValue('exclude_chans',[],@(x) ischar(x) || iscell(x));
0132 p.addParamValue('include_chans',[],@(x) ischar(x) || iscell(x));
0133 p.addParamValue('out_fname',[],@ischar);
0134 p.parse(gui_infiles_or_tmplt,varargin{:});
0135
0136
0137
0138 if ~isempty(p.Results.include_chans) && ~isempty(p.Results.exclude_chans)
0139 error('You cannot use BOTH ''include_chans'' and ''exclude_chans'' options.');
0140 end
0141 if ischar(p.Results.exclude_chans),
0142 exclude_chans{1}=p.Results.exclude_chans;
0143 elseif isempty(p.Results.exclude_chans)
0144 exclude_chans=[];
0145 else
0146 exclude_chans=p.Results.exclude_chans;
0147 end
0148 if ischar(p.Results.include_chans),
0149 include_chans{1}=p.Results.include_chans;
0150 elseif isempty(p.Results.include_chans)
0151 include_chans=[];
0152 else
0153 include_chans=p.Results.include_chans;
0154 end
0155
0156
0157
0158
0159 VERBLEVEL=2;
0160
0161
0162 GND.exp_desc=[];
0163 GND.filename=[];
0164 GND.filepath=[];
0165 GND.n_groups=1;
0166 GND.saved='no';
0167 GND.grands=[];
0168 GND.grands_stder=[];
0169 GND.grands_t=[];
0170 GND.sub_ct=[];
0171 if ~isempty(p.Results.locfile),
0172 GND.chanlocs=readlocs(p.Results.locfile,'filetype','loc');
0173 n_chanlocs=length(GND.chanlocs);
0174 use_chanlocs=ones(1,n_chanlocs);
0175 for a=1:n_chanlocs,
0176 use_chan_labels{a}=GND.chanlocs(a).labels;
0177 end
0178 if ~isempty(exclude_chans),
0179 for a=1:length(exclude_chans),
0180 found=0;
0181 for b=1:n_chanlocs,
0182 if ismember(GND.chanlocs(b).labels,exclude_chans{a}),
0183 found=1;
0184 use_chanlocs(b)=0;
0185 verbreport(sprintf('Not importing channel %s.',exclude_chans{a}),2,VERBLEVEL);
0186 end
0187 end
0188 if ~found,
0189 verbreport(sprintf('I attempted to exclude channel %s, but no such channel exists in your loc file.', ...
0190 exclude_chans{a}),2,VERBLEVEL);
0191 end
0192 end
0193 verbreport(sprintf('All other channels in locfile will be imported.'),2,VERBLEVEL);
0194 elseif ~isempty(include_chans),
0195 use_chanlocs=zeros(1,n_chanlocs);
0196 for a=1:length(include_chans),
0197 found=0;
0198 for b=1:n_chanlocs,
0199 if ismember(GND.chanlocs(b).labels,include_chans{a}),
0200 found=1;
0201 use_chanlocs(b)=1;
0202 verbreport(sprintf('Importing channel %s.',include_chans{a}),2,VERBLEVEL);
0203 end
0204 end
0205 if ~found,
0206 verbreport(sprintf('I attempted to include channel %s, but no such channel exists in your loc file.', ...
0207 include_chans{a}),2,VERBLEVEL);
0208 end
0209 end
0210 verbreport(sprintf('All other channels in locfile will NOT be imported.'),2,VERBLEVEL);
0211 end
0212 GND.chanlocs=GND.chanlocs(find(use_chanlocs));
0213 use_chan_labels=cell(1,sum(use_chanlocs));
0214 n_use_chans=sum(use_chanlocs);
0215 for a=1:n_use_chans,
0216 use_chan_labels{a}=GND.chanlocs(a).labels;
0217 end
0218 else
0219 GND.chanlocs=struct([]);
0220 end
0221
0222 GND.bin_info=[];
0223 GND.condesc=[];
0224
0225 GND.time_pts=[];
0226 GND.bsln_wind=[];
0227 GND.odelay=[];
0228 GND.srate=NaN;
0229 GND.indiv_fnames=[];
0230 GND.indiv_subnames=[];
0231 GND.indiv_traits=[];
0232 GND.indiv_bin_ct=[];
0233 GND.indiv_bin_raw_ct=[];
0234 GND.indiv_erps=[];
0235 GND.indiv_art_ics=[];
0236 GND.cals.indiv_cals=[];
0237 GND.cals.indiv_cal_ct=[];
0238 GND.cals.grand_cals=[];
0239 GND.history=[];
0240 GND.perm_tests=[];
0241
0242
0243
0244 if strcmpi(gui_infiles_or_tmplt,'GUI'),
0245 loading=1;
0246 infiles=[];
0247 while loading,
0248 [neofname, inpath]=uigetfile({'*.nrf','*.nrf files'; ...
0249 '*.mas','*.mas files'; ...
0250 '*.cms','*.cms files'; ...
0251 '*.nrm','*.nrm files'; ...
0252 '*.cnm','*.cnm files'; ...
0253 '*.iccor',' *.iccor files'; ...
0254 '*.mas;*.cms','*.mas & *.cms files'; ...
0255 '*.nrm;*.cnm','*.nrm & *.cnm files'; ...
0256 '*.*','All Files (*.*)'},'Kutaslab Average Files to Import','MultiSelect','on');
0257 if ischar(neofname),
0258 clear infname;
0259 infname{1}=neofname;
0260 else
0261 infname=neofname;
0262 end
0263 if ~inpath,
0264 if isempty(infiles),
0265 fprintf('File selection cancelled. Aborting avgs2GND.\n');
0266 GND=[];
0267 return;
0268 else
0269 loading=0;
0270 end
0271 else
0272 if isempty(infiles),
0273 infiles=cell(1,length(infname));
0274 for a=1:length(infname),
0275 infiles{a}=[inpath infname{a}];
0276 end
0277 else
0278 n_files=length(infiles);
0279 ct=0;
0280 for a=(n_files+1):(n_files+length(infname)),
0281 ct=ct+1;
0282 infiles{a}=[inpath infname{ct}];
0283 end
0284 end
0285
0286 resp=questdlg('Do you want to load more files?',...
0287 'OUTPUT','Yes','No','Yes');
0288 if strcmpi(resp,'No'),
0289 loading=0;
0290 end
0291 end
0292 end
0293 elseif iscell(p.Results.gui_infiles_or_tmplt)
0294 infiles=p.Results.gui_infiles_or_tmplt;
0295 else
0296 if isempty(p.Results.sub_ids)
0297 error('If gui_infiles_or_tmplt is a string filename template, you must specify the participant numbers with the argument ''sub_ids''.');
0298 elseif ~ismember('#',p.Results.gui_infiles_or_tmplt),
0299 error('The filename template %s need to contain a # to indicate where the participant nubmers go (e.g., odbl#.nrm).', ...
0300 p.Results.gui_infiles_or_tmplt);
0301 else
0302 lb_id=find(p.Results.gui_infiles_or_tmplt=='#');
0303 prefix=p.Results.gui_infiles_or_tmplt(1:(lb_id(1)-1));
0304 postfix=p.Results.gui_infiles_or_tmplt((lb_id(1)+1):end);
0305 n_subs=length(p.Results.sub_ids);
0306 infiles=cell(1,n_subs);
0307 for s=1:n_subs,
0308 no_pad=[prefix num2str(p.Results.sub_ids(s)) postfix];
0309 if p.Results.sub_ids(s)<10,
0310 padded=[prefix num2str(p.Results.sub_ids(s),'%.2d') postfix];
0311 [sP wP]=unix(['ls ' padded]);
0312 [sNP wNP]=unix(['ls ' no_pad]);
0313 if ~sP
0314 if ~sNP,
0315 error('You have a file named %s and one named %s. I don''t know which one to load!\n', ...
0316 padded,no_pad);
0317 else
0318 infiles{s}=padded;
0319 end
0320 else
0321 infiles{s}=no_pad;
0322 end
0323 else
0324 infiles{s}=no_pad;
0325 end
0326 end
0327 end
0328 end
0329
0330 n_subs=length(infiles);
0331 for sub=1:n_subs,
0332
0333
0334 fprintf('Opening file %s\n',infiles{sub});
0335 fid=erpio('openavg',infiles{sub});
0336 if (fid==-1)
0337 msg=erpio('get_errstr');
0338 error('Could not open file %s using erpio. According to erpio: %s', ...
0339 infiles{sub},msg);
0340 end
0341
0342
0343 n_chans=erpio('get_hdrvar',fid,'chans',1);
0344 use_chans=zeros(1,n_chans);
0345 used_chan_ct=0;
0346
0347 if ~isempty(p.Results.locfile) || (sub>1),
0348 for c=1:n_chans,
0349 chan_label=erpio('get_hdrvar',fid,'chndesc',c-1,1);
0350 if ismember(chan_label,use_chan_labels),
0351 used_chan_ct=used_chan_ct+1;
0352 if ~strcmpi(GND.chanlocs(used_chan_ct).labels,chan_label),
0353 erpio('close',fid);
0354 error('In %s, the #%d used channel is %s. In %s, it is %s.\n', ...
0355 infiles{sub},used_chan_ct,chan_label,locfile,GND.chanlocs(used_chan_ct).labels);
0356 else
0357 use_chans(c)=1;
0358 end
0359 end
0360 end
0361 if sum(use_chans)~=n_use_chans,
0362 erpio('close',fid);
0363 error('File %s has a different number of channels than all previous files.', ...
0364 infiles{sub});
0365 end
0366 else
0367
0368
0369 if n_chans>=59,
0370
0371 load('/usr/local/matlab-toolboxes/matlabmk/mk66locs');
0372 else
0373
0374 load('/usr/local/matlab-toolboxes/matlabmk/mk33locs');
0375 end
0376 n_chanlocs=length(chanlocs);
0377 for c=1:n_chans,
0378 chan_label=erpio('get_hdrvar',fid,'chndesc',c-1,1);
0379 use_chans(c)=1;
0380 if ~isempty(exclude_chans) && ismember(chan_label,exclude_chans),
0381 use_chans(c)=0;
0382 end
0383 if ~isempty(include_chans) && ~ismember(chan_label,include_chans),
0384 use_chans(c)=0;
0385 end
0386 if use_chans(c),
0387 used_chan_ct=used_chan_ct+1;
0388
0389 if strcmpi(chan_label,'lle'),
0390 avg_label='LLEy';
0391 elseif strcmpi(chan_label,'rle'),
0392 avg_label='RLEy';
0393 elseif strcmpi(chan_label,'lhe') || strcmpi(chan_label,'lhz') || ...
0394 strcmpi(chan_label,'lhrz'),
0395 avg_label='LHEy';
0396 elseif strcmpi(chan_label,'rhe') || strcmpi(chan_label,'rhz') || ...
0397 strcmpi(chan_label,'rhrz'),
0398 avg_label='RHEy';
0399 elseif strcmpi(chan_label,'HE'),
0400 avg_label='HEOG';
0401 elseif strcmpi(chan_label,'VE'),
0402 avg_label='VEOG';
0403 else
0404 avg_label=chan_label;
0405 end
0406 found=0;
0407 for d=1:n_chanlocs,
0408 if strcmpi(avg_label,chanlocs(d).labels),
0409 if used_chan_ct==1,
0410 GND.chanlocs=chanlocs(d);
0411 else
0412 GND.chanlocs(used_chan_ct)=chanlocs(d);
0413 end
0414 GND.chanlocs(used_chan_ct).labels=chan_label;
0415 found=1;
0416 end
0417 end
0418 if ~found,
0419 watchit(sprintf(['Could not find a default coordinate for channel %s. ' ...
0420 'Giving it the bogus coordinate of a few inches in front of the nose.\n'],chan_label));
0421 GND.chanlocs(used_chan_ct)=chanlocs(n_chanlocs);
0422 GND.chanlocs(used_chan_ct).labels=chan_label;
0423 end
0424 end
0425 end
0426 n_use_chans=used_chan_ct;
0427 use_chan_labels=cell(1,n_use_chans);
0428 for d=1:n_use_chans,
0429 use_chan_labels{d}=GND.chanlocs(d).labels;
0430 end
0431 end
0432
0433
0434 n_bins=erpio('getnbins',fid);
0435 if ~isempty(GND.indiv_erps),
0436 if n_bins~=total_psbl_bins,
0437 erpio('close',fid);
0438 error('File %s has %d bins. The previous files have %d bins (counting Bin 0, which should contain cal pulses).', ...
0439 infiles{sub},n_bins,total_psbl_bins);
0440 end
0441 end
0442 if sub==1,
0443 if isempty(p.Results.use_bins),
0444 use_bins=1:(n_bins-1);
0445 else
0446 use_bins=p.Results.use_bins;
0447 end
0448 total_psbl_bins=n_bins;
0449 end
0450
0451
0452 if isempty(GND.exp_desc),
0453 GND.exp_desc=erpio('get_hdrvar',fid,'expdesc',1);
0454 else
0455 neo_desc=erpio('get_hdrvar',fid,'expdesc',1);
0456 if ~strcmpi(GND.exp_desc,neo_desc),
0457 watchit(sprintf('The experiment descriptor for file %s is %s.\nUsing initial descriptor: %s.\n', ...
0458 infiles{sub},neo_desc,GND.exp_desc));
0459 end
0460 end
0461
0462
0463 if sub==1,
0464
0465 bin_ct=0;
0466 for b=use_bins,
0467 bin_ct=bin_ct+1;
0468 GND.bin_info(bin_ct).bindesc=erpio('get_hdrvar',fid,'bindesc',b);
0469 end
0470 GND.cals.caldesc=erpio('get_hdrvar',fid,'bindesc',0);
0471 else
0472
0473 bin_ct=0;
0474 for b=use_bins,
0475 bin_ct=bin_ct+1;
0476 neo_bindesc=erpio('get_hdrvar',fid,'bindesc',b);
0477 if ~strcmpi(GND.bin_info(bin_ct).bindesc,neo_bindesc),
0478 erpio('close',fid);
0479 error('The bin descriptor for file %s, Bin %d is %s. For previous file(s) it is %s.', ...
0480 infiles{sub},b,neo_bindesc,GND.bin_info(bin_ct).bindesc);
0481 end
0482 end
0483
0484 neo_bindesc=erpio('get_hdrvar',fid,'bindesc',0);
0485 if ~strcmpi(GND.cals.caldesc,neo_bindesc),
0486 erpio('close',fid);
0487 error('The bin descriptor for file %s, Bin %d is %s. For previous file(s) it is %s.', ...
0488 infiles{sub},0,neo_bindesc,GND.cals.caldesc);
0489 end
0490 end
0491
0492
0493 if sub==1,
0494
0495 bin_ct=0;
0496 for b=use_bins,
0497 bin_ct=bin_ct+1;
0498 GND.bin_info(bin_ct).condcode=erpio('get_hdrvar',fid,'condcode',b);
0499 end
0500 GND.cals.condcode=erpio('get_hdrvar',fid,'condcode',0);
0501 else
0502
0503 bin_ct=0;
0504 for b=use_bins,
0505 bin_ct=bin_ct+1;
0506 neo_ccode=erpio('get_hdrvar',fid,'condcode',b);
0507 if neo_ccode~=GND.bin_info(bin_ct).condcode,
0508 erpio('close',fid);
0509 error('The condition code for Bin %d in file %s is %d. In previous file(s) it is %d.', ...
0510 b,infiles{sub},neo_ccode,GND.bin_info(bin_ct).condcode);
0511 end
0512 end
0513
0514 neo_ccode=erpio('get_hdrvar',fid,'condcode',0);
0515 if neo_ccode~=GND.cals.condcode,
0516 erpio('close',fid);
0517 error('The condition code for Bin 0 in file %s is %d. In previous file(s) it is %d.', ...
0518 infiles{sub},neo_ccode,GND.cals.condcode);
0519 end
0520 end
0521
0522
0523 if isempty(GND.condesc),
0524
0525
0526
0527 GND.cals.condesc=erpio('get_hdrvar',fid,'condesc',0);
0528
0529 if sum(use_bins>1),
0530
0531 n_ccode=1;
0532 GND.condesc{n_ccode}=erpio('get_hdrvar',fid,'condesc',use_bins(1));
0533 if length(use_bins)>1,
0534 for b=use_bins(2:end),
0535 neo_ccdesc=erpio('get_hdrvar',fid,'condesc',b);
0536 if ~strcmpi(neo_ccdesc,GND.condesc{n_ccode}),
0537 n_ccode=n_ccode+1;
0538 GND.condesc{n_ccode}=neo_ccdesc;
0539 end
0540 end
0541 end
0542 end
0543 else
0544
0545 bin_ct=0;
0546 for b=use_bins,
0547 bin_ct=bin_ct+1;
0548 neo_condesc=erpio('get_hdrvar',fid,'condesc',b);
0549 if ~strcmpi(GND.condesc{GND.bin_info(bin_ct).condcode},neo_condesc),
0550 erpio('close',fid);
0551 error('The condition code descriptor for file %s, Bin %d is %s. For previous file(s) it is %s.', ...
0552 infiles{sub},b,neo_condesc,GND.condesc{GND.bin_info(bin_ct).condcode});
0553 end
0554 end
0555
0556 neo_condesc=erpio('get_hdrvar',fid,'condesc',0);
0557 if ~strcmpi(GND.cals.condesc,neo_condesc),
0558 erpio('close',fid);
0559 error('The condition code descriptor for file %s, Bin %d is %s. For previous file(s) it is %s.', ...
0560 infiles{sub},0,neo_condesc,GND.cals.condesc);
0561 end
0562 end
0563
0564
0565
0566 cprecis=erpio('get_hdrvar',fid,'cprecis',1);
0567 presamp=erpio('get_hdrvar',fid,'presampling',1);
0568 srate=100000/erpio('get_hdrvar',fid,'clktick',1);
0569 GND.srate=srate;
0570 if isempty(GND.time_pts),
0571 n_pts=cprecis*256;
0572 GND.time_pts=[0:(n_pts-1)]*1000/srate-presamp;
0573 if isempty(p.Results.bsln),
0574 bsln=[-presamp -1000/srate];
0575 fprintf('Using default baseline of %d to %d ms ', ...
0576 -presamp,-1000/srate);
0577 else
0578 bsln=p.Results.bsln;
0579 fprintf('Using baseline of %d to %d ms ', ...
0580 bsln(1),bsln(2));
0581 end
0582 bsln_pts=[find_tpt(bsln(1),GND.time_pts):find_tpt(bsln(2),GND.time_pts)];
0583 GND.bsln_wind=[GND.time_pts(bsln_pts(1)) GND.time_pts(bsln_pts(end))];
0584 fprintf('(%d to %d in time points)\n',bsln_pts(1),bsln_pts(end));
0585 else
0586 cprecis=erpio('get_hdrvar',fid,'cprecis',1);
0587 presamp=erpio('get_hdrvar',fid,'presampling',1);
0588 srate=100000/erpio('get_hdrvar',fid,'clktick',1);
0589 neo_pts=cprecis*256;
0590 if neo_pts~=n_pts,
0591 erpio('close',fid);
0592 error('File %s has %d time points of EEG. Previous file(s) have %d.', ...
0593 infiles{sub},neo_pts,n_pts);
0594 end
0595 neo_time_pts=[0:(n_pts-1)]*1000/srate-presamp;
0596 if sum(neo_time_pts~=GND.time_pts),
0597 erpio('close',fid);
0598 error('File %s has either a different sampling rate or prestimulus baseline than previous file(s).', ...
0599 infiles{sub});
0600 end
0601 end
0602
0603
0604 if isempty(GND.odelay),
0605 GND.odelay=erpio('get_hdrvar',fid,'odelay',1);
0606 else
0607 odelay=erpio('get_hdrvar',fid,'odelay',1);
0608 if GND.odelay~=odelay,
0609 error('File %s has an odelay of %d. Previous files have an odelay %d.', ...
0610 odelay,GND.odelay);
0611 end
0612 end
0613
0614
0615
0616 GND.indiv_fnames{sub}=infiles{sub};
0617 GND.indiv_subnames{sub}=erpio('get_hdrvar',fid,'subdesc',1);
0618
0619
0620
0621 n_use_bins=length(use_bins);
0622 if isempty(GND.indiv_erps),
0623 GND.grands=zeros(n_use_chans,n_pts,n_use_bins)*NaN;
0624 GND.grands_stder=GND.grands;
0625 GND.grands_t=GND.grands;
0626 GND.sub_ct=zeros(1,n_use_bins);
0627 GND.indiv_bin_ct=zeros(n_subs,n_use_bins);
0628 GND.indiv_bin_raw_ct=zeros(n_subs,n_use_bins);
0629 GND.indiv_erps=zeros(n_use_chans,n_pts,n_use_bins,n_subs)*NaN;
0630 GND.indiv_art_ics=cell(1,n_subs);
0631 GND.cals.indiv_cals=zeros(n_use_chans,n_pts,n_subs)*NaN;
0632 GND.cals.indiv_cal_ct=zeros(1,n_subs);
0633 GND.cals.grand_cals=zeros(n_use_chans,n_pts)*NaN;
0634 end
0635
0636
0637
0638 pp10uv=erpio('get_hdrvar',fid,'pp10uv',1);
0639 bin_ct=0;
0640 for b=use_bins,
0641 bin_ct=bin_ct+1;
0642 GND.indiv_bin_ct(sub,bin_ct)=erpio('get_hdrvar',fid,'sums',b);
0643 GND.indiv_bin_raw_ct(sub,bin_ct)=erpio('get_hdrvar',fid,'totrawrecs',b);
0644 erps=10*erpio('readbin',fid,b)/pp10uv;
0645
0646 GND.indiv_erps(:,:,bin_ct,sub)=erps;
0647 end
0648
0649
0650 GND.cals.indiv_cal_ct(sub)=erpio('get_hdrvar',fid,'totrawrecs',0);
0651 erps=10*erpio('readbin',fid,0)/pp10uv;
0652
0653 GND.cals.indiv_cals(:,:,sub)=erps;
0654
0655 erpio('close',fid);
0656
0657
0658
0659 end
0660
0661
0662
0663 for b=1:n_use_bins,
0664 bin_subs=find(GND.indiv_bin_ct(:,b));
0665 GND.sub_ct(b)=length(bin_subs);
0666 if GND.sub_ct(b),
0667 GND.grands(:,:,b)=mean(GND.indiv_erps(:,:,b,bin_subs),4);
0668 GND.grands_stder(:,:,b)=std(GND.indiv_erps(:,:,b,bin_subs),0,4)/sqrt(GND.sub_ct(b));
0669 GND.grands_t(:,:,b)=GND.grands(:,:,b)./GND.grands_stder(:,:,b);
0670 else
0671 watchit(sprintf('No average files contribute to bin %d.',b));
0672 end
0673 end
0674
0675
0676 GND.cals.grand_cals=mean(GND.cals.indiv_cals,3);
0677
0678
0679 for b=1:n_use_bins,
0680 if (GND.bin_info(b).bindesc(end)==13)
0681 GND.bin_info(b).bindesc=GND.bin_info(b).bindesc(1: ...
0682 (length(GND.bin_info(b).bindesc)-1));
0683 end
0684 end
0685 if (GND.cals.caldesc(end)==13)
0686 GND.cals.caldesc=GND.cals.caldesc(1:(length(GND.cals.caldesc)-1));
0687 end
0688
0689
0690 for b=1:length(GND.condesc),
0691 if (GND.condesc{b}(end)==13)
0692 GND.condesc{b}=GND.condesc{b}(1:length(GND.condesc{b})-1);
0693 end
0694 end
0695 if (GND.cals.condesc(end)==13)
0696 GND.cals.condesc=GND.cals.condesc(1:(length(GND.cals.condesc)-1));
0697 end
0698
0699
0700 if isempty(p.Results.out_fname),
0701
0702 [jname, jpath]=uiputfile({'*.GND','*.GND files'; ...
0703 '*.*','All files'},'Save GND variable as:','untitled.GND');
0704 if ~jpath,
0705 fprintf('Output filename selection cancelled. GND variable NOT saved to disk.\n');
0706 else
0707 GND=saveGND(GND,jname,jpath,1);
0708 end
0709 elseif ~strcmpi(p.Results.out_fname,'no save'),
0710 [jpath, jname]=pathNname(p.Results.out_fname);
0711 GND=saveGND(GND,jname,jpath);
0712 end