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