Attachment 'cbu_csv2_ui.m'
Download 1 function varargout = cbu_csv2_ui(varargin)
2 %
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 % cbuhacked version of spm_spm_ui.m
5 % Ian Nimmo-Smith, 3-11 June 1999
6 % adapted for SPM2 August 2006
7 %
8 % v0.2 handling blank lines - thanks to Joe Devlin
9 % v0.3 now runs under its own name so no conflict with
10 % spm_spm_ui.m in standard distribution
11 SCCSid = '0.3';
12 %
13 % [1] design and filename entry from a .csv file [done]
14 % [2] saving design and filename details in design.csv [done]
15 % [3] inputting covariate values from the .csv file [done]
16 %
17 % For documentation see
18 % http://imaging.mrc-cbu.cam.ac.uk/imaging/PetModelAutomation
19 %
20 % Setting up the general linear model for independent data
21 % FORMATs (given in Programmers Help)
22 %_______________________________________________________________________
23 %
24 % spm_spm_ui.m configures the design matrix (describing the general
25 % linear model), data specification, and other parameters necessary for
26 % the statistical analysis. These parameters are saved in a
27 % configuration file (SPMcfg.mat) in the current directory, and are
28 % passed on to spm_spm.m which estimates the design. Inference on these
29 % estimated parameters is then handled by the SPM results section.
30 %
31 % A separate program (spm_spm_fmri_ui.m) handles design configuration
32 % for fMRI time series, though this program can be used for fMRI data
33 % when observations can be regarded as independent.
34 %
35 % ----------------------------------------------------------------------
36 %
37 % Various data and parameters need to be supplied to specify the design:
38 % * the image files
39 % * indicators of the corresponding condition/subject/group
40 % * any covariates, nuisance variables, or design matrix partitions
41 % * the type of global normalisation (if any)
42 % * grand mean scaling options
43 % * thresholds and masks defining the image volume to analyse
44 %
45 % The interface supports a comprehensive range of options for all these
46 % parameters, which are described below in the order in which the
47 % information is requested. Rather than ask for all these parameters,
48 % spm_spm_ui.m uses a "Design Definition", a structure describing the
49 % options and defaults appropriate for a particular analysis. Thus,
50 % once the user has chosen a design, a subset of the following prompts
51 % will be presented.
52 %
53 % If the pre-specified design definitions don't quite
54 % have the combination of options you want, you can pass a custom design
55 % structure D to be used as parameter: spm_spm_ui('cfg',D). The format of
56 % the design structure and option definitions are given in the programmers
57 % help, at the top of the main body of the code.
58 %
59 % ----------------
60 %
61 % Design class & Design type
62 % ==========================
63 %
64 % Unless a design definition is passed to spm_spm_ui.m as a parameter,
65 % the user is prompted first to select a design class, and then to
66 % select a design type from that class.
67 %
68 % The designs are split into three classes:
69 % i) Basic stats: basic models for simple statistics
70 % These specify designs suitable for simple voxel-by-voxel analyses.
71 % - one-sample t-test
72 % - two-sample t-test
73 % - paired t-test
74 % - one way Anova
75 % - one way Anova (with constant)
76 % - one way Anova (within subject)
77 % - simple regression (equivalent to correlation)
78 % - multiple regression
79 % - multiple regression (with constant)
80 % - basic AnCova (ANalysis of COVAriance)
81 % (essentially a two-sample t-test with a nuisance covariate)
82 %
83 % ii) PET models: models suitable for analysis of PET/SPECT experiments
84 % - Single-subject: conditions & covariates
85 % - Single-subject: covariates only
86 %
87 % - Multi-subj: conditions & covariates
88 % - Multi-subj: cond x subj interaction & covariates
89 % - Multi-subj: covariates only
90 % - Multi-group: conditions & covariates
91 % - Multi-group: covariates only
92 %
93 % - Population main effect: 2 cond's, 1 scan/cond (paired t-test)
94 % - Dodgy population main effect: >2 cond's, 1 scan/cond
95 % - Compare-populations: 1 scan/subject (two sample t-test)
96 % - Compare-populations: 1 scan/subject (AnCova)
97 %
98 % - The Full Monty... (asks you everything!)
99 %
100 % iii) SPM96 PET models: models used in SPM96 for PET/SPECT
101 % These models are provided for backward compatibility, but as they
102 % don't include some of the advanced modelling features, we recommend
103 % you switch to the new (SPM99) models at the earliest opportunity.
104 % - SPM96:Single-subject: replicated conditions
105 % - SPM96:Single-subject: replicated conditions & covariates
106 % - SPM96:Single-subject: covariates only
107 % - SPM96:Multi-subject: different conditions
108 % - SPM96:Multi-subject: replicated conditions
109 % - SPM96:Multi-subject: different conditions & covariates
110 % - SPM96:Multi-subject: replicated conditions & covariates
111 % - SPM96:Multi-subject: covariates only
112 % - SPM96:Multi-group: different conditions
113 % - SPM96:Multi-group: replicated conditions
114 % - SPM96:Multi-group: different conditions & covariates
115 % - SPM96:Multi-group: replicated conditions & covariates
116 % - SPM96:Multi-group: covariates only
117 % - SPM96:Compare-groups: 1 scan per subject
118 %
119 %
120 % Random effects, generalisability, population inference...
121 % =========================================================
122 %
123 % Note that SPM only considers a single component of variance, the
124 % residual error variance. When there are repeated measures, all
125 % analyses with SPM are fixed effects analyses, and inference only
126 % extends to the particular subjects under consideration (at the times
127 % they were imaged).
128 %
129 % In particular, the multi-subject and multi-group designs ignore the
130 % variability in response from subject to subject. Since the
131 % scan-to-scan (within-condition, within-subject variability is much
132 % smaller than the between subject variance which is ignored), this can
133 % lead to detection of group effects that are not representative of the
134 % population(s) from which the subjects are drawn. This is particularly
135 % serious for multi-group designs comparing two groups. If inference
136 % regarding the population is required, a random effects analysis is
137 % required.
138 %
139 % However, random effects analyses can be effected by appropriately
140 % summarising the data, thereby collapsing the model such that the
141 % residual variance for the new model contains precisely the variance
142 % components needed for a random effects analysis. In many cases, the
143 % fixed effects models here can be used as the first stage in such a
144 % two-stage procedure to produce appropriate summary data, which can
145 % then be used as raw data for a second-level analysis. For instance,
146 % the "Multi-subj: cond x subj interaction & covariates" design can be
147 % used to write out an image of the activation for each subject. A
148 % simple t-test on these activation images then turns out to be
149 % equivalent to a mixed-effects analysis with random subject and
150 % subject by condition interaction effects, inferring for the
151 % population based on this sample of subjects (strictly speaking the
152 % design would have to be balanced, with equal numbers of scans per
153 % condition per subject, and also only two conditions per subject). For
154 % additional details, see spm_RandFX.man.
155 %
156 % ----------------
157 %
158 % Selecting image files & indicating conditions
159 % =============================================
160 %
161 % You may now be prompted to specify how many studies, subjects and
162 % conditions you have, and then will be promted to select the scans.
163 %
164 % The data should all have the same orientation and image and voxel size.
165 %
166 % File selection is handled by spm_get.m - the help for which describes
167 % efficient use of the interface.
168 %
169 % You may be asked to indicate the conditions for a set of scans, with
170 % a prompt like "[12] Enter conditions? (2)". For this particular
171 % example you need to indicate for 12 scans the corresponding
172 % condition, in this case from 2 conditions. Enter a vector of
173 % indicators, like '0 1 0 1...', or a string of indicators, like
174 % '010101010101' or '121212121212', or 'rararararara'. (This
175 % "conditions" input is handled by spm_input.m, where comprehensive
176 % help can be found.)
177 %
178 % ----------------
179 %
180 % Covariate & nuisance variable entry
181 % ===================================
182 %
183 % * If applicable, you'll be asked to specify covariates and nuisance
184 % variables. Unlike SPM94/5/6, where the design was partitioned into
185 % effects of interest and nuisance effects for the computation of
186 % adjusted data and the F-statistic (which was used to thresh out
187 % voxels where there appeared to be no effects of interest), SPM99 does
188 % not partition the design in this way. The only remaining distinction
189 % between effects of interest (including covariates) and nuisance
190 % effects is their location in the design matrix, which we have
191 % retained for continuity. Pre-specified design matrix partitions can
192 % be entered. (The number of covariates / nuisance variables specified,
193 % is actually the number of times you are prompted for entry, not the
194 % number of resulting design matrix columns.) You will be given the
195 % opportunity to name the covariate.
196 %
197 % * Factor by covariate interactions: For covariate vectors, you may be
198 % offered a choice of interaction options. (This was called "covariate
199 % specific fits" in SPM95/6.) The full list of possible options is:
200 % - <none>
201 % - with replication
202 % - with condition (across group)
203 % - with subject (across group)
204 % - with group
205 % - with condition (within group)
206 % - with subject (within group)
207 %
208 % * Covariate centering: At this stage may also be offered "covariate
209 % centering" options. The default is usually that appropriate for the
210 % interaction chosen, and ensures that main effects of the interacting
211 % factor aren't affected by the covariate. You are advised to choose
212 % the default, unless you have other modelling considerations. The full
213 % list of possible options is:
214 % - around overall mean
215 % - around replication means
216 % - around condition means (across group)
217 % - around subject means (across group)
218 % - around group means
219 % - around condition means (within group)
220 % - around subject means (within group)
221 % - <no centering>
222 %
223 % ----------------
224 %
225 % Global options
226 % ==============
227 %
228 % Depending on the design configuration, you may be offered a selection
229 % of global normalisation and scaling options:
230 %
231 % * Method of global flow calculation
232 % - SPM96:Compare-groups: 1 scan per subject
233 % - None (assumming no other options requiring the global value chosen)
234 % - User defined (enter your own vector of global values)
235 % - SPM standard: mean voxel value (within per image fullmean/8 mask)
236 %
237 % * Grand mean scaling : Scaling of the overall grand mean simply
238 % scales all the data by a common factor such that the mean of all the
239 % global values is the value specified. For qualitative data, this puts
240 % the data into an intuitively accessible scale without altering the
241 % statistics. When proportional scaling global normalisation is used
242 % (see below), each image is seperately scaled such that it's global
243 % value is that specified (in which case the grand mean is also
244 % implicitly scaled to that value). When using AnCova or no global
245 % normalisation, with data from different subjects or sessions, an
246 % intermediate situation may be appropriate, and you may be given the
247 % option to scale group, session or subject grand means seperately. The
248 % full list of possible options is:
249 % - scaling of overall grand mean
250 % - caling of replication grand means
251 % - caling of condition grand means (across group)
252 % - caling of subject grand means (across group)
253 % - caling of group grand means
254 % - caling of condition (within group) grand means
255 % - caling of subject (within group) grand means
256 % - implicit in PropSca global normalisation)
257 % - no grand Mean scaling>'
258 %
259 % * Global normalisation option : Global nuisance effects are usually
260 % accounted for either by scaling the images so that they all have the
261 % same global value (proportional scaling), or by including the global
262 % covariate as a nuisance effect in the general linear model (AnCova).
263 % Much has been written on which to use, and when. Basically, since
264 % proportional scaling also scales the variance term, it is appropriate
265 % for situations where the global measurement predominantly reflects
266 % gain or sensitivity. Where variance is constant across the range of
267 % global values, linear modelling in an AnCova approach has more
268 % flexibility, since the model is not restricted to a simple
269 % proportional regression.
270 %
271 % Considering AnCova global normalisation, since subjects are unlikely
272 % to have the same relationship between global and local measurements,
273 % a subject-specific AnCova ("AnCova by subject"), fitting a different
274 % slope and intercept for each subject, would be preferred to the
275 % single common slope of a straight AnCova. (Assumming there's enough
276 % scans per subject to estimate such an effect.) This is basically an
277 % interaction of the global covariate with the subject factor. You may
278 % be offered various AnCova options, corresponding to interactions with
279 % various factors according to the design definition: The full list of
280 % possible options is:
281 % - AnCova
282 % - AnCova by replication
283 % - AnCova by condition (across group)
284 % - AnCova by subject (across group)
285 % - AnCova by group
286 % - AnCova by condition (within group)
287 % - AnCova by subject (within group)
288 % - Proportional scaling
289 % - <no global normalisation>
290 %
291 % Since differences between subjects may be due to gain and sensitivity
292 % effects, AnCova by subject could be combined with "grand mean scaling
293 % by subject" to obtain a combination of between subject proportional
294 % scaling and within subject AnCova.
295 %
296 % * Global centering: Lastly, for some designs using AnCova, you will
297 % be offered a choice of centering options for the global covariate. As
298 % with covariate centering, this is only relevant if you have a
299 % particular interest in the parameter estimates. Usually, the default
300 % of a centering corresponding to the AnCova used is chosen. The full
301 % list of possible options is:
302 % - around overall mean
303 % - around replication means
304 % - around condition means (across group)
305 % - around subject means (across group)
306 % - around group means
307 % - around condition means (within group)
308 % - around subject means (within group)
309 % - <no centering>
310 % - around user specified value
311 % - (as implied by AnCova)
312 % - GM (The grand mean scaled value)
313 % - (redundant: not doing AnCova)
314 %
315 %
316 %
317 % Note that this is a logical ordering for the global options, which is
318 % not the order used by the interface due to algorithm constraints. The
319 % interface asks for the options in this order:
320 % - Global normalisation
321 % - Grand mean scaling options
322 % (if not using proportional scaling global normalisation)
323 % - Value for grand mean scaling proportional scaling GloNorm
324 % (if appropriate)
325 % - Global centering options
326 % - Value for global centering (if "user-defined" chosen)
327 % - Method of calculation
328 %
329 % ----------------
330 %
331 % Masking options
332 % ===============
333 %
334 % The mask specifies the voxels within the image volume which are to be
335 % assessed. SPM supports three methods of masking. The volume analysed
336 % is the intersection of all masks:
337 %
338 % i) Threshold masking : "Analysis threshold"
339 % - images are thresholded at a given value and only voxels at
340 % which all images exceed the threshold are included in the
341 % analysis.
342 % - The threshold can be absolute, or a proportion of the global
343 % value (after scaling), or "-Inf" for no threshold masking.
344 % - (This was called "Grey matter threshold" in SPM94/5/6)
345 %
346 % ii) Implicit masking
347 % - An "implicit mask" is a mask implied by a particular voxel
348 % value. Voxels with this mask value are excluded from the
349 % analysis.
350 % - For image data-types with a representation of NaN
351 % (see spm_type.m), NaN's is the implicit mask value, (and
352 % NaN's are always masked out).
353 % - For image data-types without a representation of NaN, zero is
354 % the mask value, and the user can choose whether zero voxels
355 % should be masked out or not.
356 %
357 % iii) Explicit masking
358 % - Explicit masks are other images containing (implicit) masks
359 % that are to be applied to the current analysis.
360 % - All voxels with value NaN (for image data-types with a
361 % representation of NaN), or zero (for other data types) are
362 % excluded from the analysis.
363 % - Explicit mask images can have any orientation and voxel/image
364 % size. Nearest neighbour interpolation of a mask image is used if
365 % the voxel centers of the input images do not coincide with that
366 % of the mask image.
367 %
368 %
369 % ----------------
370 %
371 % Non-sphericity correction
372 % =========================
373 %
374 % In some instances the i.i.d. assumptions about the errors do not hold.
375 % For example, in 2nd-level analyses serial correlations can be expressed
376 % as correlations among contrasts. If you request a non-sphericity
377 % correction you will be asked to specify whether the repeated measures
378 % are correlated over replications. It is important to ensure that the
379 % number of repeated measures (e.g. conditions) is not large in relation
380 % to the number of replications (e.g. subjects). If you say 'no' to correlated
381 % repeated measures, then SPM will assume unequal variances for each level
382 % of each factor.
383 % The non-sphericity option is offered even if there is only one factor.
384 % This allows you to model unequal variances among its levels.
385 % The ensuing covariance components will be estimated using ReML in spm_spm
386 % (assuming the same for all voxels) and used to adjust the statistics and
387 % degrees of freedom during inference. By default spm_spm will use wieghted
388 % least squares to produce Gauss-Markov or Maximum likelihood estimators
389 % using the non-sphericity strcuture specified at this stage. The components
390 % will be found in xX.xVi and enter the estimation procedure exactly as the
391 % serial correlations in fMRI models.
392 %
393 %
394 % ----------------
395 %
396 % Multivariate analyses
397 % =====================
398 %
399 % Mulitvariate analyses with n-variate response variables are supported
400 % and automatically invoke a ManCova and CVA in spm_spm. Multivariate
401 % designs are, at the moment limited to Basic and PET designs.
402 %
403 % ----------------------------------------------------------------------
404 %
405 % Variables saved in the SPM stucture
406 %
407 % xY.VY - nScan x 1 struct array of memory mapped images
408 % (see spm_vol for definition of the map structure)
409 % xX - structure describing design matrix
410 % xX.D - design definition structure
411 % (See definition in main body of spm_spm_ui.m)
412 % xX.I - nScan x 4 matrix of factor level indicators
413 % I(n,i) is the level of factor i corresponding to image n
414 % xX.sF - 1x4 cellstr containing the names of the four factors
415 % xX.sF{i} is the name of factor i
416 % xX.X - design matrix
417 % xX.xVi - correlation constraints for non-spericity correction
418 % xX.iH - vector of H partition (condition effects) indices,
419 % identifying columns of X correspoding to H
420 % xX.iC - vector of C partition (covariates of interest) indices
421 % xX.iB - vector of B partition (block effects) indices
422 % xX.iG - vector of G partition (nuisance variables) indices
423 % xX.name - p x 1 cellstr of effect names corresponding to columns
424 % of the design matrix
425 %
426 % xC - structure array of covariate details
427 % xC(i).rc - raw (as entered) i-th covariate
428 % xC(i).rcname - name of this covariate (string)
429 % xC(i).c - covariate as appears in design matrix (after any scaling,
430 % centering of interactions)
431 % xC(i).cname - cellstr containing names for effects corresponding to
432 % columns of xC(i).c
433 % xC(i).iCC - covariate centering option
434 % xC(i).iCFI - covariate by factor interaction option
435 % xC(i).type - covariate type: 1=interest, 2=nuisance, 3=global
436 % xC(i).cols - columns of design matrix corresponding to xC(i).c
437 % xC(i).descrip - cellstr containing a description of the covariate
438 %
439 % xGX - structure describing global options and values
440 % xGX.iGXcalc - global calculation option used
441 % xGX.sGXcalc - string describing global calculation used
442 % xGX.rg - raw globals (before scaling and such like)
443 % xGX.iGMsca - grand mean scaling option
444 % xGX.sGMsca - string describing grand mean scaling
445 % xGX.GM - value for grand mean (/proportional) scaling
446 % xGX.gSF - global scaling factor (applied to xGX.rg)
447 % xGX.iGC - global covariate centering option
448 % xGX.sGC - string describing global covariate centering option
449 % xGX.gc - center for global covariate
450 % xGX.iGloNorm - Global normalisation option
451 % xGX.sGloNorm - string describing global normalisation option
452 %
453 % xM - structure describing masking options
454 % xM.T - Threshold masking value (-Inf=>None,
455 % real=>absolute, complex=>proportional (i.e. times global) )
456 % xM.TH - nScan x 1 vector of analysis thresholds, one per image
457 % xM.I - Implicit masking (0=>none, 1=>implicit zero/NaN mask)
458 % xM.VM - struct array of explicit mask images
459 % (empty if no explicit masks)
460 % xM.xs - structure describing masking options
461 % (format is same as for xsDes described below)
462 %
463 % xsDes - structure of strings describing the design:
464 % Fieldnames are essentially topic strings (use "_"'s for
465 % spaces), and the field values should be strings or cellstr's
466 % of information regarding that topic. spm_DesRep.m
467 % uses this structure to produce a printed description
468 % of the design, displaying the fieldnames (with "_"'s
469 % converted to spaces) in bold as topics, with
470 % the corresponding text to the right
471 %
472 % SPMid - String identifying SPM and program versions
473 %
474 % ----------------
475 %
476 % NB: The SPM.mat file is not very portable: It contains
477 % memory-mapped handles for the images, which hardcodes the full file
478 % pathname and datatype. Therefore, subsequent to creating the
479 % SPM.mat, you cannot move the image files, and cannot move the
480 % entire analysis to a system with a different byte-order (even if the
481 % full file pathnames are retained. Further, the image scalefactors
482 % will have been pre-scaled to effect any grand mean or global
483 % scaling.
484 %_______________________________________________________________________
485 % @(#)spm_spm_ui.m 2.49 Andrew Holmes 03/03/20
486 %SCCSid = '2.49';
487
488 %=======================================================================
489 % - FORMAT specifications for programers
490 %=======================================================================
491 %( This is a multi function function, the first argument is an action )
492 %( string, specifying the particular action function to take. )
493 %
494 % FORMAT spm_spm_ui('CFG',D)
495 % Configure design
496 % D - design definition structure - see format definition below
497 % (If D is a struct array, then the user is asked to choose from the
498 % design definitions in the array. If D is not specified as an
499 % argument, then user is asked to choose from the standard internal
500 % definitions)
501 %
502 % FORMAT [P,I] = spm_spm_ui('Files&Indices',DsF,Dn,DbaTime)
503 % PET/SPECT file & factor level input
504 % DsF - 1x4 cellstr of factor names (ie D.sF)
505 % Dn - 1x4 vector indicating the number of levels (ie D.n)
506 % DbaTime - ask for F3 images in time order, with F2 levels input by user?
507 % P - nScan x 1 cellsrt of image filenames
508 % I - nScan x 4 matrix of factor level indices
509 %
510 % FORMAT D = spm_spm_ui('DesDefs_Stats')
511 % Design definitions for simple statistics
512 % D - struct array of design definitions (see definition below)
513 %
514 % FORMAT D = spm_spm_ui('DesDefs_PET')
515 % Design definitions for PET/SPECT models
516 % D - struct array of design definitions (see definition below)
517 %
518 % FORMAT D = spm_spm_ui('DesDefs_PET96')
519 % Design definitions for SPM96 PET/SPECT models
520 % D - struct array of design definitions (see definition below)
521
522 %=======================================================================
523 % Design definitions specification for programers & power users
524 %=======================================================================
525 % Within spm_spm_ui.m, a definition structure, D, determines the
526 % various options, defaults and specifications appropriate for a
527 % particular design. Usually one uses one of the pre-specified
528 % definitions chosen from the menu, which are specified in the function
529 % actions at the end of the program (spm_spm_ui('DesDefs_Stats'),
530 % spm_spm_ui('DesDefs_PET'), spm_spm_ui('DesDefs_PET96')). For
531 % customised use of spm_spm_ui.m, the design definition structure is
532 % shown by the following example:
533 %
534 % D = struct(...
535 % 'DesName','The Full Monty...',...
536 % 'n',[Inf Inf Inf Inf], 'sF',{{'repl','cond','subj','group'}},...
537 % 'Hform', 'I(:,[4,2]),''-'',{''stud'',''cond''}',...
538 % 'Bform', 'I(:,[4,3]),''-'',{''stud'',''subj''}',...
539 % 'nC',[Inf,Inf],'iCC',{{[1:8],[1:8]}},'iCFI',{{[1:7],[1:7]}},...
540 % 'iGXcalc',[1,2,3],'iGMsca',[1:7],'GM',50,...
541 % 'iGloNorm',[1:9],'iGC',[1:11],...
542 % 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
543 % 'b',struct('aTime',1));
544 %
545 % ( Note that the struct command expands cell arrays to give multiple )
546 % ( records, so if you want a cell array as a field value, you have to )
547 % ( embed it within another cell, hence the double "{{"'s. )
548 %
549 % ----------------
550 %
551 % Design structure fields and option definitions
552 % ==============================================
553 %
554 % D.Desname - a string naming the design
555 %
556 % In general, spm_spm_ui.m accomodates four factors. Usually these are
557 % 'group', 'subject', 'condition' & 'replication', but to allow for a
558 % flexible interface these are dynamically named for different designs,
559 % and are referred to as Factor4, Factor3, Factor2, and Factor1
560 % respectively. The first part of the D definition dictates the names
561 % and number of factor levels (i.e. number of subjects etc.) relevant
562 % for this design, and also how the H (condition) and B (block)
563 % partitions of the design matrix should be constructed.
564 %
565 % D.n - a 1x4 vector, indicating the number of levels. D.n(i)
566 % for i in [1:4] is the number of levels for factor i.
567 % Specify D.n(i) as 1 to ignore this factor level,
568 % otherwise the number of levels can be pre-specified as a
569 % given number, or given as Inf to allow the user to
570 % choose the number of levels.
571 %
572 % D.sF - a 1x4 cellstr containing the names of the four
573 % factors. D.sF{i} is the name of factor i.
574 %
575 % D.b.aTime - a binary indicator specifying whether images within F3
576 % level (subject) are selected in time order. For time
577 % order (D.b.aTime=1), F2 levels are indicated by a user
578 % input "condition" string (input handled by spm_input's
579 % 'c' type). When (D.b.aTime=0), images for each F3 are
580 % selected by F2 (condition). The latter was the mode of
581 % SPM95 and SPM96. (SPM94 and SPMclassic didn't do
582 % replications of conditions.)
583 %
584 % Once the user has entered the images and indicated the factor levels,
585 % a nScan x 4 matrix, I, of indicator variables is constructed
586 % specifying for each scan the relevant level of each of the four
587 % factors. I(n,i) is the level of factor i corresponding to image n.
588 % This I matrix of factor indicators is then used to construct the H
589 % and B forms of the design matrix according to the prescripton in the
590 % design definition D:
591 %
592 % D.Hform - a string specifying the form of the H partition of the
593 % design matrix. The string is evaluated as an argument
594 % string for spm_DesMtx, which builds design matrix
595 % partitions from indicator vectors.
596 % (eval(['[H,Hnames] = spm_DesMtx(',D.Hform,');']))
597 %
598 % D.BForm - a string specifying the form of the G partition.
599 %
600 % ( Note that a constant H partition is dropped if the B partition can )
601 % ( model the constant effect. )
602 %
603 % The next part of the design definition defines covariate options.
604 % Covariates are split into covariates (of interest) and nuisance
605 % variables. The covariates of interest and nuisance variables are put
606 % into the C & G partitions of the design matrox (the final design
607 % matrix is [H,C,B,G], where global nuisance covariates are appended to
608 % G). In SPM94/5/6 the design matrix was partitioned into effects of
609 % interest [H,C] and effects of no interest [B,G], with an F-test for
610 % no effects of interest and adjusted data (for effects of no interest)
611 % following from these partitions. SPM99 is more freestyle, with
612 % adjustments and F-tests specified by contrasts. However, the concept
613 % of effects of interest and of no interest has been maintained for
614 % continuity, and spm_spm_ui.m computes an F-contrast to test for "no
615 % effects of interest".
616 %
617 % D.nC - a 1x2 vector: D.nC(1) is the number of covariates,
618 % D.nC(2) the number of nuisance variables. Specify zero
619 % to skip covariate entry, the actual number of
620 % covariates, or Inf to let the user specify the number of
621 % covariates. As with earlier versions, blocks of design
622 % matrix can be entered. However, these are now treated as
623 % a single covariate entity, so the number of
624 % covariates.nuisance variables is now the number of items
625 % you are prompted for, regardless of their dimension. (In
626 % SPM95-6 this number was the number of covariate vectors
627 % that could be entered.)
628 %
629 % D.iCC - a 1x2 cell array containing two vectors indicating the
630 % allowable covariate centering options for this design.
631 % These options are defined in the body of spm_spm_ui.m,
632 % in variables sCC & CFIforms. Use negative indices to
633 % indicate the default, if any - the largest negative
634 % wins.
635 %
636 % D.iCFI - a 1x2 cell array containing two vectors indicating the
637 % allowable covariate by factor interactions for this
638 % design. Interactions are only offered with a factor if
639 % it has multiple levels. The options are defined in the
640 % body of spm_spm_ui.m, in variables sCFI & CFIforms. Use
641 % negative indicies to indicate a default.
642 %
643 % The next part defines global options:
644 %
645 % D.iGXcalc - a vector of possible global calculation options for
646 % this design, as listed in the body of spm_spm_ui.m in
647 % variable sGXcalc. (If other global options are chosen,
648 % then the "omit" option is not offered.) Again, negative
649 % values indicate a default.
650 %
651 % D.iGloNorm - a vector of possible global normalisation options for
652 % this design, as described in the body of spm_spm_ui.m in
653 % variable sGloNorm.
654 %
655 % D.iGMsca - a vector of possible grand mean scaling options, as
656 % described in the body of spm_spm_ui.m in variable
657 % sGMsca. (Note that grand mean scaling is redundent when
658 % using proportional scaling global flow normalisation.)
659 %
660 % D.iGC - a vector of possible global covariate centering
661 % options, corresponding to the descriptions in variable
662 % iCC given in the body of spm_spm_ui.m. This is only
663 % relevant for AnCova type global normalisation, and even
664 % then only if you're actually interested in constraining
665 % the values of the parameters in some useful way.
666 % Usually, one chooses option 10, "as implied by AnCova".
667 %
668 % The next component specifies masking options:
669 %
670 % D.M_.T - a vector defining the analysis threshold: Specify
671 % "-Inf" as an element to offer "None" as an option. If a
672 % real element is found, then absolute thresholding is
673 % offered, with the first real value proffered as default
674 % threshold. If an imaginary element is found, then
675 % proportional thresholding if offered (i.e. the threshold
676 % is a proportion of the image global), with the (abs of)
677 % the first imaginary element proffered as default.
678 %
679 % D.M_.I - Implicit masking? 0-no, 1-yes, Inf-ask. (This is
680 % irrelevant for image types with a representation of NaN,
681 % since NaN is then the mask value, and NaN's are always
682 % masked.)
683 %
684 % D.M.X - Explicit masking? 0-no, 1-yes, Inf-ask.
685 %
686 % ----------------
687 %
688 % To use a customised design structure D, type spm_spm_ui('cfg',D) in the
689 % Matlab command window.
690 %
691 % The easiest way to generate a customised design definition structure
692 % is to tweak one of the pre-defined definitions. The following code
693 % will prompt you to select one of the pre-defined designs, and return
694 % the design definition structure for you to work on:
695 %
696 % D = spm_spm_ui(char(spm_input('Select design class...','+1','m',...
697 % {'Basic stats','Standard PET designs','SPM96 PET designs'},...
698 % {'DesDefs_Stats','DesDefs_PET','DesDefs_PET96'},2)));
699 % D = D(spm_input('Select design type...','+1','m',{D.DesName}'))
700 %
701 %_______________________________________________________________________
702 % @(#)spm_spm_ui.m 2.49 Andrew Holmes 03/03/20
703
704
705 %-Condition arguments
706 %-----------------------------------------------------------------------
707
708 global defaults
709 if isempty(defaults)
710 spm_defaults;
711 end
712
713 if (nargin==0), Action = 'CFG'; else, Action = varargin{1}; end
714
715
716 switch lower(Action), case 'cfg'
717 %=======================================================================
718 % - C O N F I G U R E D E S I G N
719 %=======================================================================
720 % spm_spm_ui('CFG',D)
721 if nargin<2, D = []; else, D = varargin{2}; end
722
723 %-GUI setup
724 %-----------------------------------------------------------------------
725 SPMid = ['SPM2: ',mfilename,' v',SCCSid];
726 [Finter,Fgraph,CmdLine] = spm('FnUIsetup','Stats: Setup analysis',0);
727 spm_help('!ContextHelp',mfilename)
728
729
730 %-Ask about overwriting files from previous analyses...
731 %-----------------------------------------------------------------------
732 if exist(fullfile('.','SPM.mat'))
733 str = { 'Current directory contains existing SPM file:',...
734 'Continuing will overwrite existing file!'};
735 if spm_input(str,1,'bd','stop|continue',[1,0],1,mfilename);
736 fprintf('%-40s: %30s\n\n',...
737 'Abort... (existing SPM file)',spm('time'))
738 spm_clf(Finter)
739 return
740 end
741 end
742
743
744
745 %-Option definitions
746 %-----------------------------------------------------------------------
747 %-Generic factor names
748 sF = {'sF1','sF2','sF3','sF4'};
749
750 %-Covariate by factor interaction options
751 sCFI = {'<none>';... %-1
752 'with sF1';'with sF2';'with sF3';'with sF4';... %-2:5
753 'with sF2 (within sF4)';'with sF3 (within sF4)'}; %-6,7
754
755 %-DesMtx argument components for covariate by factor interaction options
756 % (Used for CFI's Covariate Centering (CC), GMscale & Global normalisation)
757 CFIforms = { '[]', 'C', '{}';... %-1
758 'I(:,1)', 'FxC', '{D.sF{1}}';... %-2
759 'I(:,2)', 'FxC', '{D.sF{2}}';... %-3
760 'I(:,3)', 'FxC', '{D.sF{3}}';... %-4
761 'I(:,4)', 'FxC', '{D.sF{4}}';... %-5
762 'I(:,[4,2])', 'FxC', '{D.sF{4},D.sF{2}}';... %-6
763 'I(:,[4,3])', 'FxC', '{D.sF{4},D.sF{3}}' }; %-7
764
765 %-Centre (mean correction) options for covariates & globals (CC)
766 % (options 9-12 are for centering of global when using AnCova GloNorm) (GC)
767 sCC = { 'around overall mean';... %-1
768 'around sF1 means';... %-2
769 'around sF2 means';... %-3
770 'around sF3 means';... %-4
771 'around sF4 means';... %-5
772 'around sF2 (within sF4) means';... %-6
773 'around sF3 (within sF4) means';... %-7
774 '<no centering>';... %-8
775 'around user specified value';... %-9
776 '(as implied by AnCova)';... %-10
777 'GM';... %-11
778 '(redundant: not doing AnCova)'}'; %-12
779 %-DesMtx I forms for covariate centering options
780 CCforms = {'ones(nScan,1)',CFIforms{2:end,1},''}';
781
782
783 %-Global normalization options (options 1-7 match CFIforms) (GloNorm)
784 sGloNorm = { 'AnCova';... %-1
785 'AnCova by sF1';... %-2
786 'AnCova by sF2';... %-3
787 'AnCova by sF3';... %-4
788 'AnCova by sF4';... %-5
789 'AnCova by sF2 (within sF4)';... %-6
790 'AnCova by sF3 (within sF4)';... %-7
791 'proportional scaling';... %-8
792 '<no global normalisation>'}; %-9
793
794 %-Grand mean scaling options (GMsca)
795 sGMsca = { 'scaling of overall grand mean';... %-1
796 'scaling of sF1 grand means';... %-2
797 'scaling of sF2 grand means';... %-3
798 'scaling of sF3 grand means';... %-4
799 'scaling of sF4 grand means';... %-5
800 'scaling of sF2 (within sF4) grand means';... %-6
801 'scaling of sF3 (within sF4) grand means';... %-7
802 '(implicit in PropSca global normalisation)';... %-8
803 '<no grand Mean scaling>' }; %-9
804 %-NB: Grand mean scaling by subject is redundent for proportional scaling
805
806
807 %-Global calculation options (GXcalc)
808 sGXcalc = { 'omit';... %-1
809 'user specified';... %-2
810 'mean voxel value (within per image fullmean/8 mask)'}; %-3
811
812
813
814 %=======================================================================
815 %-D E S I G N P A R A M E T E R S
816 %=======================================================================
817 %-Get design type
818 %-----------------------------------------------------------------------
819
820 D = [D, struct(...
821 'DesName','Bespoke design via CBU CSV interface',...
822 'n',[Inf Inf Inf Inf], 'sF',{{'repl','condition','subject','group'}},...
823 'Hform', 'I(:,[4,2]),''-'',{''stud'',''cond''}',...
824 'Bform', 'I(:,[4,3]),''-'',{''stud'',''subj''}',...
825 'nC',[Inf,Inf],'iCC',{{[5:8],[5,7,8]}},'iCFI',{{[1,5,6,7],[1,5,7]}},...
826 'iGXcalc',[1,2,-3],'iGMsca',[-7,9],'GM',50,...
827 'iGloNorm',[7,8,9],'iGC',10,...
828 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
829 'b',struct('aTime',1))];
830
831 if isempty(D)
832
833 D = spm_spm_ui( ...
834 char(spm_input('Select design class...','+1','m',...
835 {'Basic stats','Standard PET designs','SPM96 PET designs'},...
836 {'DesDefs_Stats','DesDefs_PET','DesDefs_PET96'},2)));
837 end
838
839 %D = D(spm_input('Select design type...','+1','m',{D.DesName}'));
840
841
842 %-Set factor names for this design
843 %-----------------------------------------------------------------------
844 sCC = sf_estrrep(sCC,[sF',D.sF']);
845 sCFI = sf_estrrep(sCFI,[sF',D.sF']);
846 sGloNorm = sf_estrrep(sGloNorm,[sF',D.sF']);
847 sGMsca = sf_estrrep(sGMsca,[sF',D.sF']);
848
849 %-Get filenames & factor indicies
850 %-----------------------------------------------------------------------
851 %%%%%%%%%%%%%%
852 %start cbuhack
853 %%%%%%%%%%%%%%
854
855 cbu_title='untitled';
856 cbu_factors='GSCR';
857 cbu_factor_format='%d,%d,%d,%d,';
858 cbu_cov_columns=0;
859 cbu_cov_partition={};
860 cbu_cov_block_labels={};
861 cbu_cov_format='';
862 cbu_covariates=[];
863
864 str = { 'Do you want to read filename/condition stuff',...
865 'from an ascii file?'};
866 cbuhack = spm_input(str,1,'bd','yes|no',[1,0],0,'CBU file input ');
867 if cbuhack
868 [P,I, ...
869 cbu_title, ...
870 cbu_factors, ...
871 cbu_factor_format, ...
872 cbu_cov_columns, ...
873 cbu_cov_partition, ...
874 cbu_cov_block_labels, ...
875 cbu_cov_format, ...
876 cbu_covariates] ...
877 = cbu_csv2_ui('cbuhack',D.sF,D.n,D.b.aTime);
878 else
879 [P,I] = spm_spm_ui('Files&Indices',D.sF,D.n,D.b.aTime); %-Files & indices
880 end
881
882 save I I;
883
884 %%%%%%%%%%%%
885 %end cbuhack
886 %%%%%%%%%%%%
887 %%[P,I] = spm_spm_ui('Files&Indices',D.sF,D.n,D.b.aTime);
888
889 nScan = size(I,1); %-#obs
890
891 %-Additional design parameters
892 %-----------------------------------------------------------------------
893 bL = any(diff(I,1),1); %-Multiple factor levels?
894 % NB: bL(2) might be thrown by user specified f1 levels
895 % (D.b.aTime & D.n(2)>1) - assumme user is consistent?
896 bFI = [bL(1),bL(2:3)&~bL(4),bL(4),bL([2,3])&bL(4)];
897 %-Allowable interactions for covariates
898 %-Only offer interactions with multi-level factors, and
899 % don't offer by F2|F3 if bL(4)!
900
901 %-Build Condition (H) and Block (B) partitions
902 %=======================================================================
903 eval(['[H,Hnames] = spm_DesMtx(',D.Hform,');'])
904 if rank(H)==nScan, error('unestimable condition effects'), end
905 eval(['[B,Bnames] = spm_DesMtx(',D.Bform,');'])
906 if rank(B)==nScan, error('unestimable block effects'), end
907
908 %-Drop a constant H partition if B partition can model constant
909 if size(H,2)>0 & all(H(:)==1) & (rank([H B])==rank(B))
910 H = []; Hnames = {};
911 warning('Dropping redundant constant H partition')
912 end
913
914
915 %-Covariate partition(s): interest (C) & nuisance (G) excluding global
916 %=======================================================================
917 nC = D.nC; %-Default #covariates
918 C = {[],[]}; Cnames = {{},{}}; %-Covariate DesMtx partitions & names
919 xC = []; %-Struct array to hold raw covariates
920
921
922 dcname = {'CovInt','NusCov'}; %-Default root names for covariates
923 dstr = {'covariate','nuisance variable'};
924
925 GUIpos = spm_input('!NextPos');
926 nc = [0,0];
927 for i = 1:2 % 1:covariates of interest, 2:nuisance variables
928
929 if ~cbuhack
930 if isinf(nC(i)), nC(i)=spm_input(['# ',dstr{i},'s'],GUIpos,'w1');, end
931 else
932 if size(cbu_cov_partition,2)<i
933 nC(i)=0;
934 else
935 nC(i)=size(cbu_cov_partition{i},2);
936 end
937 end
938
939 while nc(i) < nC(i)
940
941 %-Create prompt, get covariate, get covariate name
942 %---------------------------------------------------------------
943 if nC(i)==1, str=dstr{i}; else, str=sprintf('%s %d',dstr{i},nc(i)+1); end
944
945 if ~cbuhack
946 c = spm_input(str,GUIpos,'r',[],[nScan,Inf]);
947 cbu_cov_partition{i}{nc(i)+1} = ...
948 (cbu_cov_columns+1):(cbu_cov_columns+size(c,2));
949 cbu_cov_columns = cbu_cov_columns+size(c,2);
950 cbu_covariates = [cbu_covariates, c];
951 else
952 c = cbu_covariates(:,cbu_cov_partition{i}{nc(i)+1});
953 end
954
955 if any(isnan(c(:))), break, end %-NaN is dummy value to exit
956 nc(i) = nc(i)+1; %-#Covariates (so far)
957 if nC(i)>1, tstr = sprintf('%s^{%d}',dcname{i},nc(i));
958 else, tstr = dcname{i}; end
959
960 if ~cbuhack
961 cname = spm_input([str,' name?'],'+1','s',tstr);
962 cbu_cov_block_labels{i}{nc(i)} = cname;
963 else
964 cname = cbu_cov_block_labels{i}{nc(i)};
965 end
966
967 rc = c; %-Save covariate value
968 rcname = cname; %-Save covariate name
969
970 %-Interaction option? (if single covariate vector entered)?
971 %---------------------------------------------------------------
972 if size(c,2) == 1
973 if length(D.iCFI{i})>1
974 %-User choice of interaction options, default is negative
975 %-Only offer interactions for appropriate factor combinations
976 iCFI = intersect(abs(D.iCFI{i}),find([1,bFI]));
977 dCFI = max([1,intersect(iCFI,-D.iCFI{i}(D.iCFI{i}<0))]);
978 iCFI = spm_input([str,': interaction?'],'+1','m',...
979 sCFI(iCFI),iCFI,find(iCFI==dCFI));
980 else
981 iCFI = abs(D.iCFI{i}); %-AutoSelect default option
982 end
983 else
984 iCFI = 1;
985 end
986
987 %-Centre covariate(s)? (Default centring to correspond to CFI)
988 % Always offer "no centering" as default for design matrix blocks
989 %---------------------------------------------------------------
990 DiCC = D.iCC{i};
991 if size(c,2)>1, DiCC = union(DiCC,-8); end
992 if length(DiCC)>1
993 %-User has a choice of centering options
994 %-Only offer factor specific for appropriate factor combinations
995 iCC = intersect(abs(DiCC),find([1,bFI,1]) );
996 %-Default is max -ve option in D, overridden by iCFI if CFI
997 if iCFI == 1, dCC = -DiCC(DiCC<0); else, dCC = iCFI; end
998 dCC = max([1,intersect(iCC,dCC)]);
999 iCC = spm_input([str,': centre?'],'+1','m',...
1000 sCC(iCC),iCC,find(iCC==dCC));
1001 else
1002 iCC = abs(DiCC); %-AutoSelect default option
1003 end
1004 %-Centre within factor levels as appropriate
1005 if any(iCC == [1:7]), c = c - spm_meanby(c,eval(CCforms{iCC})); end
1006
1007 %-Do any interaction (only for single covariate vectors)
1008 %---------------------------------------------------------------
1009 if iCFI > 1 %-(NB:iCFI=1 if size(c,2)>1)
1010 tI = [eval(CFIforms{iCFI,1}),c];
1011 tConst = CFIforms{iCFI,2};
1012 tFnames = [eval(CFIforms{iCFI,3}),{cname}];
1013 [c,cname] = spm_DesMtx(tI,tConst,tFnames);
1014 elseif size(c,2)>1 %-Design matrix block
1015 [null,cname] = spm_DesMtx(c,'X',cname);
1016 else
1017 cname = {cname};
1018 end
1019
1020 %-Store raw covariate details in xC struct for reference
1021 %-Pack c into appropriate DesMtx partition
1022 %---------------------------------------------------------------
1023 %-Construct description string for covariate
1024 str = {sprintf('%s: %s',str,rcname)};
1025 if size(rc,2)>1, str = {sprintf('%s (block of %d covariates)',...
1026 str{:},size(rc,2))}; end
1027 if iCC < 8, str=[str;{['used centered ',sCC{iCC}]}]; end
1028 if iCFI> 1, str=[str;{['fitted as interaction ',sCFI{iCFI}]}]; end
1029
1030 tmp = struct( 'rc',rc, 'rcname',rcname,...
1031 'c',c, 'cname',{cname},...
1032 'iCC',iCC, 'iCFI',iCFI,...
1033 'type',i,...
1034 'cols',[1:size(c,2)] + ...
1035 size([H,C{1}],2) + ...
1036 size([B,C{2}],2)*(i-1),...
1037 'descrip',{str} );
1038 if isempty(xC), xC = tmp; else, xC = [xC,tmp]; end
1039 C{i} = [C{i},c];
1040 Cnames{i} = [Cnames{i}; cname];
1041
1042 end % (while)
1043
1044 end % (for)
1045 clear c tI tConst tFnames
1046 spm_input('!SetNextPos',GUIpos);
1047
1048 %%%%%%%%%%%%%%%%%%%%%%%%%%
1049 %start cbuhack save design
1050 %%%%%%%%%%%%%%%%%%%%%%%%%%
1051
1052 csv=fopen('design.csv','w'); % save design/file data in design.csv
1053
1054 cbu_full='GSCR';
1055 cbu_f='';
1056 cbu_o='';
1057 cbu_w='';
1058 for i = 1:4
1059 if length(unique(I(:,5-i)))>1
1060 cbu_f=[cbu_f,cbu_full(i)];
1061 cbu_o=[cbu_o,'%d, '];
1062 cbu_w=[cbu_w,'I(i,',int2str(5-i),'), '];
1063 end
1064 end
1065
1066 fprintf(csv,'=cbu_title=''%s'';\n=cbu_factors=''%s'';\n=cbu_cov_columns=[%s];\n', ...
1067 cbu_title,cbu_f,int2str(cbu_cov_columns));
1068
1069 part='';
1070 labs='';
1071 if size(cbu_cov_partition,2)>0
1072 part = [part, '=cbu_cov_partition={'];
1073 labs = [labs, '=cbu_cov_block_labels={'];
1074 for i=1:size(cbu_cov_partition,2)
1075 if size(cbu_cov_partition{i},2)>0
1076 part = [part, '{'];
1077 labs = [labs, '{'];
1078 for j=1:size(cbu_cov_partition{i},2)
1079 part = [part, sprintf('[%s],',int2str(cbu_cov_partition{i}{j}))];
1080 labs = [labs, sprintf('''%s'',',cbu_cov_block_labels{i}{j})];
1081 end
1082 part = [part, '}, '];
1083 labs = [labs, '}, '];
1084 end
1085 end
1086 part = [part, '};\n'];
1087 labs = [labs, '};\n'];
1088 end
1089
1090 fprintf(csv,strrep(strrep(part,',}','}'),', }','}'));
1091 fprintf(csv,strrep(strrep(labs,',}','}'),', }','}'));
1092
1093 fprintf(csv,'+\n');
1094
1095 for i=1:size(I,1)
1096 eval(strrep(['fprintf(csv,''',cbu_o,''',',cbu_w,');'],', )',')'));
1097 for j=1:size(cbu_covariates,2)
1098 fprintf(csv,'%g, ',cbu_covariates(i,j));
1099 end %j
1100 fprintf(csv,'%s\n',P{i});
1101 end %i
1102 fclose(csv);
1103
1104 %%%%%%%%%%%%%%%%%%%%%%%%
1105 %end cbuhack save design
1106 %%%%%%%%%%%%%%%%%%%%%%%%
1107
1108 %-Unpack into C & G design matrix sub-partitions
1109 G = C{2}; Gnames = Cnames{2};
1110 C = C{1}; Cnames = Cnames{1};
1111
1112
1113 %-Options...
1114 %=======================================================================
1115 %-Global normalization options (GloNorm)
1116 %-----------------------------------------------------------------------
1117 if length(D.iGloNorm)>1
1118 %-User choice of global normalisation options, default is negative
1119 %-Only offer factor specific for appropriate factor combinations
1120 iGloNorm = intersect(abs(D.iGloNorm),find([1,bFI,1,1]));
1121 dGloNorm = max([0,intersect(iGloNorm,-D.iGloNorm(D.iGloNorm<0))]);
1122 iGloNorm = spm_input('GloNorm: Select global normalisation','+1','m',...
1123 sGloNorm(iGloNorm),iGloNorm,find(iGloNorm==dGloNorm));
1124 else
1125 iGloNorm = abs(D.iGloNorm);
1126 end
1127
1128
1129 %-Grand mean scaling options (GMsca)
1130 %-----------------------------------------------------------------------
1131 if iGloNorm==8
1132 iGMsca=8; %-grand mean scaling implicit in PropSca GloNorm
1133 elseif length(D.iGMsca)==1
1134 iGMsca = abs(D.iGMsca);
1135 else
1136 %-User choice of grand mean scaling options
1137 %-Only offer factor specific for appropriate factor combinations
1138 iGMsca = intersect(abs(D.iGMsca),find([1,bFI,0,1]));
1139 %-Default is max -ve option in D, overridden by iGloNorm if AnCova
1140 if iGloNorm==9, dGMsca=-D.iGMsca(D.iGMsca<0); else, dGMsca=iGloNorm; end
1141 dGMsca = max([0,intersect(iGMsca,dGMsca)]);
1142 iGMsca = spm_input('GMsca: grand mean scaling','+1','m',...
1143 sGMsca(iGMsca),iGMsca,find(iGMsca==dGMsca));
1144 end
1145
1146
1147 %-Value for PropSca / GMsca (GM)
1148 %-----------------------------------------------------------------------
1149 if iGMsca == 9 %-Not scaling (GMsca or PropSca)
1150 GM = 0; %-Set GM to zero when not scaling
1151 else %-Ask user value of GM
1152 if iGloNorm==8
1153 str = 'PropSca global mean to';
1154 else
1155 str = [strrep(sGMsca{iGMsca},'scaling of','scale'),' to'];
1156 end
1157 GM = spm_input(str,'+1','r',D.GM,1);
1158 %-If GM is zero then don't GMsca! or PropSca GloNorm
1159 if GM==0, iGMsca=9; if iGloNorm==8, iGloNorm=9; end, end
1160 end
1161
1162 %-Sort out description strings for GloNorm and GMsca
1163 %-----------------------------------------------------------------------
1164 sGloNorm = sGloNorm{iGloNorm};
1165 sGMsca = sGMsca{iGMsca};
1166 if iGloNorm==8
1167 sGloNorm = sprintf('%s to %-4g',sGloNorm,GM);
1168 elseif iGMsca<8
1169 sGMsca = sprintf('%s to %-4g',sGMsca,GM);
1170 end
1171
1172
1173 %-Global centering (for AnCova GloNorm) (GC)
1174 %-----------------------------------------------------------------------
1175 %-Specify the centering option for the global covariate for AnCova
1176 %-Basically, if 'GMsca'ling then should centre to GM (iGC=11). Otherwise,
1177 % should centre in similar fashion to AnCova (i.e. by the same factor(s)),
1178 % such that models are seperable (iGC=10). This is particularly important
1179 % for subject specific condition effects if then passed on to a second-level
1180 % model. (See also spm_adjmean_ui.m) SPM96 (& earlier) used to just centre
1181 % GX around its (overall) mean (iGC=1).
1182
1183 %-This code allows more general options to be specified (but is a bit complex)
1184 %-Setting D.iGC=[-10,-11] gives the standard choices above
1185
1186 %-If not doing AnCova then GC is irrelevant
1187 if ~any(iGloNorm == [1:7])
1188 iGC = 12;
1189 gc = [];
1190 else
1191 %-Annotate options 10 & 11 with specific details
1192 %---------------------------------------------------------------
1193 %-Tag '(as implied by AnCova)' with actual AnCova situation
1194 sCC{10} = [sCC{iGloNorm},' (<= ',sGloNorm,')'];
1195 %-Tag 'GM' case with actual GM & GMsca case
1196 sCC{11} = sprintf('around GM=%g (i.e. %s after grand mean scaling)',...
1197 GM,strrep(sCC{iGMsca},'around ',''));
1198
1199 %-Constuct vector of allowable iGC
1200 %---------------------------------------------------------------
1201 %-Weed out redundent factor combinations from pre-set allowable options
1202 iGC = intersect(abs(D.iGC),find([1,bFI,1,1,1,1]));
1203 %-Omit 'GM' option if didn't GMsca (iGMsca~=8 'cos doing AnCova)
1204 if any(iGMsca==[8,9]), iGC = setdiff(iGC,11); end
1205 %-Omit 'GM' option if same as '(as implied by AnCova)'
1206 if iGloNorm==iGMsca, iGC = setdiff(iGC,11); end
1207
1208 %-If there's a choice, set defaults (if any), & get answer
1209 %---------------------------------------------------------------
1210 if length(iGC)>1
1211 dGC = max([0,intersect(iGC,-D.iGC(D.iGC<0))]);
1212 str = 'Centre global covariate';
1213 if iGMsca<8, str = [str,' (after grand mean scaling)']; end
1214 iGC = spm_input(str,'+1','m',sCC(iGC),iGC,find(iGC==dGC));
1215 elseif isempty(iGC)
1216 error('Configuration error: empty iGC')
1217 end
1218
1219 %-If 'user specified' then get value
1220 %---------------------------------------------------------------
1221 if iGC==9
1222 gc = spm_input('Centre globals around','+0','r',D.GM,1);
1223 sCC{9} = sprintf('%s of %g',sCC{iGC},gc);
1224 else
1225 gc = 0;
1226 end
1227 end
1228
1229
1230 %-Thresholds & masks defining voxels to analyse (MASK)
1231 %=======================================================================
1232 GUIpos = spm_input('!NextPos');
1233
1234 %-Analysis threshold mask
1235 %-----------------------------------------------------------------------
1236 %-Work out available options:
1237 % -Inf=>None, real=>absolute, complex=>proportional, (i.e. times global)
1238 M_T = D.M_.T; if isempty(M_T), M_T = [-Inf, 100, 0.8*sqrt(-1)]; end
1239 M_T = { 'none', M_T(min(find(isinf(M_T))));...
1240 'absolute', M_T(min(find(isfinite(M_T)&(M_T==real(M_T)))));...
1241 'relative', M_T(min(find(isfinite(M_T)&(M_T~=real(M_T))))) };
1242
1243 %-Work out available options
1244 %-If there's a choice between proportional and absolute then ask
1245 %-----------------------------------------------------------------------
1246 q = ~[isempty(M_T{1,2}), isempty(M_T{2,2}), isempty(M_T{3,2})];
1247
1248 if all(q(2:3))
1249 tmp = spm_input('Threshold masking',GUIpos,'b',M_T(q,1),find(q));
1250 q(setdiff([1:3],tmp))=0;
1251 end
1252
1253 %-Get mask value - note that at most one of q(2:3) is true
1254 %-----------------------------------------------------------------------
1255 if ~any(q) %-Oops - nothing specified!
1256 M_T = -Inf;
1257 elseif all(q==[1,0,0]) %-no threshold masking
1258 M_T = -Inf;
1259 else %-get mask value
1260 if q(1), args = {'br1','None',-Inf,abs(M_T{1+find(q(2:3)),2})};
1261 else, args = {'r',abs(M_T{1+find(q(2:3)),2})}; end
1262 if q(2)
1263 M_T = spm_input('threshold',GUIpos,args{:});
1264 elseif q(3)
1265 M_T = spm_input('threshold (relative to global)',GUIpos,...
1266 args{:});
1267 if isfinite(M_T) & isreal(M_T), M_T=M_T*sqrt(-1); end
1268 else
1269 error('Shouldn''t get here!')
1270 end
1271 end
1272
1273 %-Make a description string
1274 %-----------------------------------------------------------------------
1275 if isinf(M_T)
1276 xsM.Analysis_threshold = 'None (-Inf)';
1277 elseif isreal(M_T)
1278 xsM.Analysis_threshold = sprintf('images thresholded at %6g',M_T);
1279 else
1280 xsM.Analysis_threshold = sprintf(['images thresholded at %6g ',...
1281 'times global'],imag(M_T));
1282 end
1283
1284
1285 %-Implicit masking: Ignore zero voxels in low data-types?
1286 %-----------------------------------------------------------------------
1287 % (Implicit mask is NaN in higher data-types.)
1288 type = getfield(spm_vol(P{1,1}),'dim')*[0,0,0,1]';
1289 if ~spm_type(type,'nanrep')
1290 switch D.M_.I
1291 case Inf, M_I = spm_input('Implicit mask (ignore zero''s)?',...
1292 '+1','y/n',[1,0],1); %-Ask
1293 case {0,1}, M_I = D.M_.I; %-Pre-specified
1294 otherwise, error('unrecognised D.M_.I type')
1295 end
1296
1297 if M_I, xsM.Implicit_masking = 'Yes: zero''s treated as missing';
1298 else, xsm.Implicit_masking = 'No'; end
1299 else
1300 M_I = 1;
1301 xsM.Implicit_masking = 'Yes: NaN''s treated as missing';
1302 end
1303
1304
1305 %-Explicit mask images (map them later...)
1306 %-----------------------------------------------------------------------
1307 switch(D.M_.X)
1308 case Inf, M_X = spm_input('explicitly mask images?','+1','y/n',[1,0],2);
1309 case {0,1}, M_X = D.M_.X;
1310 otherwise, error('unrecognised D.M_.X type')
1311 end
1312 if M_X, M_P = spm_get(Inf,'*.img',{'select mask images'}); else, M_P = {}; end
1313
1314
1315 %-Global calculation (GXcalc)
1316 %=======================================================================
1317 iGXcalc = abs(D.iGXcalc);
1318 %-Only offer "omit" option if not doing any GloNorm, GMsca or PropTHRESH
1319 if ~(iGloNorm==9 & iGMsca==9 & (isinf(M_T)|isreal(M_T)))
1320 iGXcalc = intersect(iGXcalc,[2:size(sGXcalc,1)]);
1321 end
1322 if isempty(iGXcalc)
1323 error('no GXcalc options')
1324 elseif length(iGXcalc)>1
1325 %-User choice of global calculation options, default is negative
1326 dGXcalc = max([1,intersect(iGXcalc,-D.iGXcalc(D.iGXcalc<0))]);
1327 iGXcalc = spm_input('Global calculation','+1','m',...
1328 sGXcalc(iGXcalc),iGXcalc,find(iGXcalc==dGXcalc));
1329 else
1330 iGXcalc = abs(D.iGXcalc);
1331 end
1332
1333 if iGXcalc==2 %-Get user specified globals
1334 g = spm_input('globals','+0','r',[],[nScan,1]);
1335 end
1336 sGXcalc = sGXcalc{iGXcalc};
1337
1338
1339 % Non-sphericity correction
1340 %=======================================================================
1341
1342 % if there are multilevel factors, ask for correction
1343 %-----------------------------------------------------------------------
1344 if length(find(max(I) > 1)) > 1
1345 xVi.iid = spm_input('non-sphericity correction?','+1','y/n',[0,1],1);
1346 else
1347 xVi.iid = 1;
1348 end
1349
1350
1351 if xVi.iid
1352
1353 % i.i.d. assumptions where xVi.V = 1
1354 %---------------------------------------------------------------
1355 xVi.V = speye(nScan);
1356
1357 else
1358 % otherwise, we have repeated measures design
1359 %===============================================================
1360 nL = max(I); % number of levels
1361 mL = find(nL > 1); % multilevel factors
1362 xVi.I = I;
1363 xVi.sF = D.sF;
1364 xVi.var = sparse(1,4);
1365 xVi.dep = sparse(1,4);
1366
1367
1368 % eliminate replication factor from mL
1369 %---------------------------------------------------------------
1370 for i = 1:4
1371 mstr{i} = sprintf('%s (%i)',D.sF{i},nL(i));
1372 end
1373 str = 'replications are over?';
1374 rep = spm_input(str,'+1','m',mstr(mL),1:length(mL));
1375
1376 % and ask whether repeated measures are independent
1377 %---------------------------------------------------------------
1378 str = 'correlated repeated measures';
1379 dep = spm_input(str,'+1','b',{'yes','no'},[1 0],1);
1380
1381
1382 %-Place covariance components Q{:} in xVi.Vi
1383 %---------------------------------------------------------------
1384 mL(rep) = [];
1385 xVi.var(mL) = 1;
1386 xVi.dep(mL) = dep;
1387 xVi = spm_non_sphericity(xVi);
1388
1389 end
1390
1391
1392 %=======================================================================
1393 % - C O N F I G U R E D E S I G N
1394 %=======================================================================
1395 spm('FigName','Stats: configuring',Finter,CmdLine);
1396 spm('Pointer','Watch');
1397
1398
1399 %-Images & image info: Map Y image files and check consistency of
1400 % dimensions and orientation / voxel size
1401 %=======================================================================
1402 fprintf('%-40s: ','Mapping files') %-#
1403 VY = spm_vol(char(P));
1404
1405
1406 %-Check compatability of images (Bombs for single image)
1407 %-----------------------------------------------------------------------
1408 if any(any(diff(cat(1,VY(:).dim),1,1),1) & [1,1,1,0])
1409 error('images do not all have the same dimensions')
1410 end
1411 if any(any(any(diff(cat(3,VY(:).mat),1,3),3)))
1412 error('images do not all have same orientation & voxel size')
1413 end
1414
1415 fprintf('%30s\n','...done') %-#
1416
1417
1418 %-Global values, scaling and global normalisation
1419 %=======================================================================
1420 %-Compute global values
1421 %-----------------------------------------------------------------------
1422 switch iGXcalc, case 1
1423 %-Don't compute => no GMsca (iGMsca==9) or GloNorm (iGloNorm==9)
1424 g = [];
1425 case 2
1426 %-User specified globals
1427 case 3
1428 %-Compute as mean voxel value (within per image fullmean/8 mask)
1429 g = zeros(nScan,1 );
1430 fprintf('%-40s: %30s','Calculating globals',' ') %-#
1431 for i = 1:nScan
1432 str = sprintf('%3d/%-3d',i,nScan);
1433 fprintf('%s%30s',sprintf('\b')*ones(1,30),str)%-#
1434 g(i) = spm_global(VY(i));
1435 end
1436 fprintf('%s%30s\n',sprintf('\b')*ones(1,30),'...done') %-#
1437 otherwise
1438 error('illegal iGXcalc')
1439 end
1440 rg = g;
1441
1442
1443 fprintf('%-40s: ','Design configuration') %-#
1444
1445
1446 %-Scaling: compute global scaling factors gSF required to implement proportional
1447 % scaling global normalisation (PropSca) or grand mean scaling (GMsca),
1448 % as specified by iGMsca (& iGloNorm)
1449 %-----------------------------------------------------------------------
1450 switch iGMsca, case 8
1451 %-Proportional scaling global normalisation
1452 if iGloNorm~=8, error('iGloNorm-iGMsca(8) mismatch for PropSca'), end
1453 gSF = GM./g;
1454 g = GM*ones(nScan,1);
1455 case {1,2,3,4,5,6,7}
1456 %-Grand mean scaling according to iGMsca
1457 gSF = GM./spm_meanby(g,eval(CCforms{iGMsca}));
1458 g = g.*gSF;
1459 case 9
1460 %-No grand mean scaling
1461 gSF = ones(nScan,1);
1462 otherwise
1463 error('illegal iGMsca')
1464 end
1465
1466
1467 %-Apply gSF to memory-mapped scalefactors to implement scaling
1468 %-----------------------------------------------------------------------
1469 for i = 1:nScan
1470 VY(i).pinfo(1:2,:) = VY(i).pinfo(1:2,:)*gSF(i);
1471 end
1472
1473
1474 %-AnCova: Construct global nuisance covariates partition (if AnCova)
1475 %-----------------------------------------------------------------------
1476 if any(iGloNorm == [1:7])
1477
1478 %-Centre global covariate as requested
1479 %---------------------------------------------------------------
1480 switch iGC, case {1,2,3,4,5,6,7} %-Standard sCC options
1481 gc = spm_meanby(g,eval(CCforms{iGC}));
1482 case 8 %-No centering
1483 gc = 0;
1484 case 9 %-User specified centre
1485 %-gc set above
1486 case 10 %-As implied by AnCova option
1487 gc = spm_meanby(g,eval(CCforms{iGloNorm}));
1488 case 11 %-Around GM
1489 gc = GM;
1490 otherwise %-unknown iGC
1491 error('unexpected iGC value')
1492 end
1493
1494
1495 %-AnCova - add scaled centred global to DesMtx `G' partition
1496 %---------------------------------------------------------------
1497 rcname = 'global';
1498 tI = [eval(CFIforms{iGloNorm,1}),g - gc];
1499 tConst = CFIforms{iGloNorm,2};
1500 tFnames = [eval(CFIforms{iGloNorm,3}),{rcname}];
1501 [f,gnames] = spm_DesMtx(tI,tConst,tFnames);
1502 clear tI tConst tFnames
1503
1504 %-Save GX info in xC struct for reference
1505 %---------------------------------------------------------------
1506 str = {sprintf('%s: %s',dstr{2},rcname)};
1507 if any(iGMsca==[1:7]), str=[str;{['(after ',sGMsca,')']}]; end
1508 if iGC ~= 8, str=[str;{['used centered ',sCC{iGC}]}]; end
1509 if iGloNorm > 1
1510 str=[str;{['fitted as interaction ',sCFI{iGloNorm}]}];
1511 end
1512 tmp = struct( 'rc',rg.*gSF, 'rcname',rcname,...
1513 'c',f, 'cname' ,{gnames},...
1514 'iCC',iGC, 'iCFI' ,iGloNorm,...
1515 'type', 3,...
1516 'cols',[1:size(f,2)] + size([H C B G],2),...
1517 'descrip', {str} );
1518
1519 G = [G,f]; Gnames = [Gnames; gnames];
1520 if isempty(xC), xC = tmp; else, xC = [xC,tmp]; end
1521
1522
1523 elseif iGloNorm==8 | iGXcalc>1
1524
1525 %-Globals calculated, but not AnCova: Make a note of globals
1526 %---------------------------------------------------------------
1527 if iGloNorm==8
1528 str = { 'global values: (used for proportional scaling)';...
1529 '("raw" unscaled globals shown)'};
1530 elseif isfinite(M_T) & ~isreal(M_T)
1531 str = { 'global values: (used to compute analysis threshold)'};
1532 else
1533 str = { 'global values: (computed but not used)'};
1534 end
1535
1536 rcname ='global';
1537 tmp = struct( 'rc',rg, 'rcname',rcname,...
1538 'c',{[]}, 'cname' ,{{}},...
1539 'iCC',0, 'iCFI' ,0,...
1540 'type', 3,...
1541 'cols', {[]},...
1542 'descrip', {str} );
1543
1544 if isempty(xC), xC = tmp; else, xC = [xC,tmp]; end
1545 end
1546
1547
1548 %-Save info on global calculation in xGX structure
1549 %-----------------------------------------------------------------------
1550 xGX = struct(...
1551 'iGXcalc',iGXcalc, 'sGXcalc',sGXcalc, 'rg',rg,...
1552 'iGMsca',iGMsca, 'sGMsca',sGMsca, 'GM',GM,'gSF',gSF,...
1553 'iGC', iGC, 'sGC', sCC{iGC}, 'gc', gc,...
1554 'iGloNorm',iGloNorm, 'sGloNorm',sGloNorm);
1555
1556
1557
1558 %-Construct masking information structure and compute actual analysis
1559 % threshold using scaled globals (rg.*gSF)
1560 %-----------------------------------------------------------------------
1561 if isreal(M_T), M_TH = M_T * ones(nScan,1); %-NB: -Inf is real
1562 else, M_TH = imag(M_T) * (rg.*gSF); end
1563
1564 if ~isempty(M_P)
1565 VM = spm_vol(char(M_P));
1566 xsM.Explicit_masking = [{'Yes: mask images :'};{VM.fname}'];
1567 else
1568 VM = [];
1569 xsM.Explicit_masking = 'No';
1570 end
1571 xM = struct('T',M_T, 'TH',M_TH, 'I',M_I, 'VM',{VM}, 'xs',xsM);
1572
1573
1574 %-Construct full design matrix (X), parameter names and structure (xX)
1575 %=======================================================================
1576 X = [H C B G];
1577 tmp = cumsum([size(H,2), size(C,2), size(B,2), size(G,2)]);
1578 xX = struct( 'X', X,...
1579 'iH', [1:size(H,2)],...
1580 'iC', [1:size(C,2)] + tmp(1),...
1581 'iB', [1:size(B,2)] + tmp(2),...
1582 'iG', [1:size(G,2)] + tmp(3),...
1583 'name', {[Hnames; Cnames; Bnames; Gnames]},...
1584 'I', I,...
1585 'sF', {D.sF});
1586
1587
1588 %-Design description (an nx2 cellstr) - for saving and display
1589 %=======================================================================
1590 tmp = { sprintf('%d condition, +%d covariate, +%d block, +%d nuisance',...
1591 size(H,2),size(C,2),size(B,2),size(G,2));...
1592 sprintf('%d total, having %d degrees of freedom',...
1593 size(X,2),rank(X));...
1594 sprintf('leaving %d degrees of freedom from %d images',...
1595 size(X,1)-rank(X),size(X,1)) };
1596 xsDes = struct( 'Design', {D.DesName},...
1597 'Global_calculation', {sGXcalc},...
1598 'Grand_mean_scaling', {sGMsca},...
1599 'Global_normalisation', {sGloNorm},...
1600 'Parameters', {tmp} );
1601
1602
1603 fprintf('%30s\n','...done') %-#
1604
1605
1606
1607 %-Assemble SPM structure
1608 %=======================================================================
1609 SPM.xY.P = P; % filenames
1610 SPM.xY.VY = VY; % mapped data
1611 SPM.nscan = size(xX.X,1); % scan number
1612 SPM.xX = xX; % design structure
1613 SPM.xC = xC; % covariate structure
1614 SPM.xGX = xGX; % global structure
1615 SPM.xVi = xVi; % non-sphericity structure
1616 SPM.xM = xM; % mask structure
1617 SPM.xsDes = xsDes; % description
1618 SPM.SPMid = SPMid; % version
1619
1620 %-Save SPM.mat and set output argument
1621 %-----------------------------------------------------------------------
1622 fprintf('%-40s: ','Saving SPM configuration') %-#
1623 save SPM SPM;
1624 fprintf('%30s\n','...SPM.mat saved') %-#
1625 varargout = {SPM};
1626
1627 %-Display Design report
1628 %=======================================================================
1629 fprintf('%-40s: ','Design reporting') %-#
1630 fname = cat(1,{SPM.xY.VY.fname}');
1631 spm_DesRep('DesMtx',SPM.xX,fname,SPM.xsDes)
1632 fprintf('%30s\n','...done')
1633
1634
1635 %-End: Cleanup GUI
1636 %=======================================================================
1637 spm_clf(Finter)
1638 spm('Pointer','Arrow')
1639 fprintf('%-40s: %30s\n','Completed',spm('time')) %-#
1640 spm('FigName','Stats: configured',Finter,CmdLine);
1641 spm('Pointer','Arrow')
1642 fprintf('\n\n')
1643
1644
1645
1646 case 'files&indices'
1647 %=======================================================================
1648 % - Get files and factor indices
1649 %=======================================================================
1650 % [P,I] = spm_spm_ui('Files&Indices',DsF,Dn,DbaTime,nV)
1651 % DbaTime=D.b.aTime; Dn=D.n; DsF=D.sF;
1652 if nargin<5, nV = 1; else, nV = varargin{5}; end
1653 if nargin<4, DbaTime = 1; else, DbaTime = varargin{4}; end
1654 if nargin<3, Dn = [Inf,Inf,Inf,Inf]; else, Dn=varargin{3}; end
1655 if nargin<2, DsF = {'Fac1','Fac2','Fac3','Fac4'}; else, DsF=varargin{2}; end
1656
1657 %-Initialise variables
1658 %-----------------------------------------------------------------------
1659 i4 = []; % factor 4 index (usually group)
1660 i3 = []; % factor 3 index (usually subject), per f4
1661 i2 = []; % factor 2 index (usually condition), per f3/f4
1662 i1 = []; % factor 1 index (usually replication), per f2/f3/f4
1663 P = {}; % cell array of string filenames
1664
1665 %-Accrue filenames and factor level indicator vectors
1666 %-----------------------------------------------------------------------
1667 bMV = nV>1;
1668 if isinf(Dn(4)), n4 = spm_input(['#',DsF{4},'''s'],'+1','n1');
1669 else, n4 = Dn(4); end
1670 bL4 = n4>1;
1671
1672 ti2 = '';
1673 GUIpos = spm_input('!NextPos');
1674 for j4 = 1:n4
1675 spm_input('!SetNextPos',GUIpos);
1676 sF4P=''; if bL4, sF4P=[DsF{4},' ',int2str(j4),': ']; end
1677 if isinf(Dn(3)), n3=spm_input([sF4P,'#',DsF{3},'''s'],'+1','n1');
1678 else, n3 = Dn(3); end
1679 bL3 = n3>1;
1680
1681 if DbaTime & Dn(2)>1
1682 %disp('NB:selecting in time order - manually specify conditions')
1683 %-NB: This means f2 levels might not be 1:n2
1684 GUIpos2 = spm_input('!NextPos');
1685 for j3 = 1:n3
1686 sF3P=''; if bL3, sF3P=[DsF{3},' ',int2str(j3),': ']; end
1687 str = [sF4P,sF3P];
1688 tP = {};
1689 n21 = Dn(2)*Dn(1);
1690 for v=1:nV
1691 vstr=''; if bMV, vstr=sprintf(' (var-%d)',v); end
1692 ttP = spm_get(n21,'.img',{[str,'select images',vstr]});
1693 n21 = length(ttP);
1694 tP = [tP,ttP];
1695 end
1696 ti2 = spm_input([str,' ',DsF{2},'?'],GUIpos2,'c',ti2',n21,Dn(2));
1697 %-Work out i1 & check
1698 [tl2,null,j] = unique(ti2);
1699 tn1 = zeros(size(tl2)); ti1 = zeros(size(ti2));
1700 for i=1:length(tl2)
1701 tn1(i)=sum(j==i); ti1(ti2==tl2(i))=1:tn1(i); end
1702 if isfinite(Dn(1)) & any(tn1~=Dn(1))
1703 %-#i1 levels mismatches specification in Dn(1)
1704 error(sprintf('#%s not %d as pre-specified',DsF{1},Dn(1)))
1705 end
1706 P = [P;tP];
1707 i4 = [i4; j4*ones(n21,1)];
1708 i3 = [i3; j3*ones(n21,1)];
1709 i2 = [i2; ti2];
1710 i1 = [i1; ti1];
1711 end
1712
1713 else
1714
1715 if isinf(Dn(2))
1716 n2 = spm_input([sF4P,'#',DsF{2},'''s'],'+1','n1');
1717 else
1718 n2 = Dn(2);
1719 end
1720 bL2 = n2>1;
1721
1722 if n2==1 & Dn(1)==1 %-single scan per f3 (subj)
1723 %disp('NB:single scan per f3')
1724 str = [sF4P,'select images, ',DsF{3},' 1-',int2str(n3)];
1725 tP = {};
1726 for v=1:nV
1727 vstr=''; if bMV, vstr=sprintf(' (var-%d)',v); end
1728 ttP = spm_get(n3,'.img',{[str,vstr]});
1729 tP = [tP,ttP];
1730 end
1731 P = [P;tP];
1732 i4 = [i4; j4*ones(n3,1)];
1733 i3 = [i3; [1:n3]'];
1734 i2 = [i2; ones(n3,1)];
1735 i1 = [i1; ones(n3,1)];
1736 else
1737 %-multi scan per f3 (subj) case
1738 %disp('NB:multi scan per f3')
1739 for j3 = 1:n3
1740 sF3P=''; if bL3, sF3P=[DsF{3},' ',int2str(j3),': ']; end
1741 if Dn(1)==1
1742 %-No f1 (repl) within f2 (cond)
1743 %disp('NB:no f1 within f2')
1744 str = [sF4P,sF3P,'select images: ',DsF{2},...
1745 ' 1-',int2str(n2)];
1746 tP = {};
1747 for v=1:nV
1748 vstr=''; if bMV, vstr=sprintf(' (var-%d)',v); end
1749 ttP = spm_get(n2,'.img',{[str,vstr]});
1750 tP = [tP,ttP];
1751 end
1752 P = [P;tP];
1753 i4 = [i4; j4*ones(n2,1)];
1754 i3 = [i3; j3*ones(n2,1)];
1755 i2 = [i2; [1:n2]'];
1756 i1 = [i1; ones(n2,1)];
1757 else
1758 %-multi f1 (repl) within f2 (cond)
1759 %disp('NB:f1 within f2')
1760 for j2 = 1:n2
1761 sF2P='';
1762 if bL2, sF2P=[DsF{2},' ',int2str(j2),': ']; end
1763 str = [sF4P,sF3P,sF2P,' select images...'];
1764 tP = {};
1765 n1 = Dn(1);
1766 for v=1:nV
1767 vstr=''; if bMV, vstr=sprintf(' (var-%d)',v); end
1768 ttP = spm_get(n1,'.img',{[str,vstr]});
1769 n1 = length(ttP);
1770 tP = [tP,ttP];
1771 end
1772 P = [P;tP];
1773 i4 = [i4; j4*ones(n1,1)];
1774 i3 = [i3; j3*ones(n1,1)];
1775 i2 = [i2; j2*ones(n1,1)];
1776 i1 = [i1; [1:n1]'];
1777 end % (for j2)
1778 end % (if Dn(1)==1)
1779 end % (for j3)
1780 end % (if n2==1 &...)
1781 end % (if DbaTime & Dn(2)>1)
1782 end % (for j4)
1783 varargout = {P,[i1,i2,i3,i4]};
1784
1785 %%%%%%%%%%%%%%
1786 %start cbuhack
1787 %
1788
1789 case 'cbuhack'
1790 %=======================================================================
1791 % - Get files and factor indices from a file
1792 %=======================================================================
1793 % [P,I] = spm_spm_ui('cbuhack',DsF,Dn,DbaTime)
1794 % DbaTime=D.b.aTime; Dn=D.n; DsF=D.sF;
1795 if nargin<4, DbaTime = 1; else, DbaTime = varargin{4}; end
1796 if nargin<3, Dn = [Inf,Inf,Inf,Inf]; else, Dn=varargin{3}; end
1797 if nargin<2, DsF = {'Fac1','Fac2','Fac3','Fac4'}; else, DsF=varargin{2}; end
1798
1799 %-Initialise variables
1800 %-----------------------------------------------------------------------
1801 i4 = []; % factor 4 index (usually group)
1802 i3 = []; % factor 3 index (usually subject), per f4
1803 i2 = []; % factor 2 index (usually condition), per f3/f4
1804 i1 = []; % factor 1 index (usually replication), per f2/f3/f4
1805 P = {}; % cell array of string filenames
1806 cbu_covariates = [];
1807
1808 cbufilestuff=spm_get(1,'.csv',{});
1809 hash='';
1810 at='';
1811 start=0;
1812 cbu_factors='';
1813 cbu_factor_format='';
1814 cbu_indices='';
1815 cbu_cov_columns=0;
1816 cbu_cov_partition={};
1817 cbu_cov_block_labels={};
1818 cbu_cov_format='';
1819 cbu_count=[];
1820 cbuf=fopen(cbufilestuff{1},'r');
1821 cellstring='tmpstring=[''a'',int2str(t4),''b'',int2str(t3),''c'',int2str(t2)];';
1822 fullstring='GSCR';
1823
1824 while (feof(cbuf) == 0)
1825
1826 line = fgetl(cbuf);
1827
1828 if size(line, 2) == 0
1829 line='%'; % ignore blank lines
1830 end
1831
1832 if strcmp(line(1),'=') % '=' initialises stuff
1833 eval(line(2:size(line,2)));
1834
1835 elseif strcmp(line(1),'+') % '+' marks end of preamble
1836 start=1;
1837 if isempty(cbu_factors)
1838 cbu_factor_format='%d,%d,%d,%d,';
1839 cbu_factor_columns=4;
1840 else
1841 cbu_factor_columns=size(cbu_factors,2);
1842 end %cbu_factors
1843
1844 for j = 1:3
1845 i=findstr(fullstring(j),cbu_factors);
1846 if i
1847 cbu_factor_format = [cbu_factor_format,'%d,'];
1848 cbu_indices=[cbu_indices,'t',int2str(5-j),'=cbu_line(',int2str(i),');'];
1849 else
1850 cbu_indices=[cbu_indices,'t',int2str(5-j),'=1;'];
1851 end %if
1852 end %j
1853
1854 i=findstr('R',cbu_factors);
1855 if i
1856 cbu_factor_format = [cbu_factor_format,'%d,'];
1857 cbu_indices=[cbu_indices,'t1=cbu_line(',int2str(i),');'];
1858 else
1859 cbu_indices=[cbu_indices,cellstring,'if isfield(cbu_count,tmpstring),',...
1860 'tmpcnt=getfield(cbu_count,tmpstring)+1;',...
1861 't1=tmpcnt;cbu_count=setfield(cbu_count,tmpstring,tmpcnt);,',...
1862 'else t1=1;cbu_count=setfield(cbu_count,tmpstring,1);,end'];
1863 end %if
1864
1865 if cbu_cov_columns==0
1866 cbu_cov_format='';
1867 cbu_cov_blocknos=0;
1868 else
1869 for i = 1:cbu_cov_columns
1870 cbu_cov_format=[cbu_cov_format,'%g,'];
1871 end
1872 if isempty(cbu_cov_partition)
1873 cbu_cov_format='';
1874 cbu_cov_blocknos=0;
1875 else
1876 cbu_cov_blocknos=size(cbu_cov_partition,2);
1877 end
1878 end %cbu_cov_columns
1879
1880 cbu_columns=cbu_factor_columns+cbu_cov_columns;
1881
1882 elseif strcmp(line(1),'#') % '#' indicates a change of super-directory
1883 hash=strrep(line(2:size(line,2)),' ','');
1884
1885 elseif strcmp(line(1),'@') % '@' indicates a change subdirectory
1886 at=strrep(line(2:size(line,2)),' ','');
1887
1888 elseif ~strcmp(line(1),'%') % '%' is an ignorable comment line
1889 cbu_line = sscanf(line,[cbu_factor_format,cbu_cov_format,'%s\n']);
1890 cbu_file=char(cbu_line(cbu_columns+1:size(cbu_line,1))');
1891 cbu_covs = cbu_line(cbu_factor_columns+1:cbu_columns)';
1892 eval(cbu_indices);
1893 if findstr('#',cbu_file) | findstr('@',cbu_file)
1894 cbu_file = strrep(strrep(cbu_file,'#',hash),'@',at);
1895 elseif strncmp(cbu_file,'/',1)
1896 cbu_file = cbu_file;
1897 else
1898 cbu_file = [hash,at,cbu_file];
1899 end
1900 i4 = [i4; t4];
1901 i3 = [i3; t3];
1902 i2 = [i2; t2];
1903 i1 = [i1; t1];
1904 P = [ P; cellstr(strrep(cbu_file,' ',''))];
1905 cbu_covariates=[cbu_covariates;cbu_covs];
1906 end %if
1907 end %while
1908 fclose(cbuf);
1909 varargout = {P,[i1,i2,i3,i4], ...
1910 cbu_title, ...
1911 cbu_factors, ...
1912 cbu_factor_format, ...
1913 cbu_cov_columns, ...
1914 cbu_cov_partition, ...
1915 cbu_cov_block_labels, ...
1916 cbu_cov_format, ...
1917 cbu_covariates};
1918 %
1919 %end cbuhack
1920 %%%%%%%%%%%%
1921
1922 case 'desdefs_stats'
1923 %=======================================================================
1924 % - Basic Stats Design definitions...
1925 %=======================================================================
1926 % D = spm_spm_ui('DesDefs_Stats');
1927 % These are the basic Stats design definitions...
1928
1929 %-Note: struct expands cell array values to give multiple records:
1930 % => must embed cell arrays within another cell array!
1931 %-Negative indices indicate defaults (first used)
1932
1933 D = struct(...
1934 'DesName','One sample t-test',...
1935 'n', [Inf 1 1 1], 'sF',{{'obs','','',''}},...
1936 'Hform', 'I(:,2),''-'',''mean''',...
1937 'Bform', '[]',...
1938 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
1939 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
1940 'iGloNorm',9,'iGC',12,...
1941 'M_',struct('T',-Inf,'I',Inf,'X',Inf),...
1942 'b',struct('aTime',0));
1943
1944 D = [D, struct(...
1945 'DesName','Two sample t-test',...
1946 'n', [Inf 2 1 1], 'sF',{{'obs','group','',''}},...
1947 'Hform', 'I(:,2),''-'',''group''',...
1948 'Bform', 'I(:,3),''-'',''\mu''',...
1949 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
1950 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
1951 'iGloNorm',9,'iGC',12,...
1952 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
1953 'b',struct('aTime',1))];
1954
1955 D = [D, struct(...
1956 'DesName','Paired t-test',...
1957 'n', [1 2 Inf 1], 'sF',{{'','cond','pair',''}},...
1958 'Hform', 'I(:,2),''-'',''condition''',...
1959 'Bform', 'I(:,3),''-'',''\gamma''',...
1960 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
1961 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
1962 'iGloNorm',9,'iGC',12,...
1963 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
1964 'b',struct('aTime',0))];
1965
1966 D = [D, struct(...
1967 'DesName','One way Anova',...
1968 'n', [Inf Inf 1 1], 'sF',{{'repl','group','',''}},...
1969 'Hform', 'I(:,2),''-'',''group''',...
1970 'Bform', '[]',...
1971 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
1972 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
1973 'iGloNorm',9,'iGC',12,...
1974 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
1975 'b',struct('aTime',0))];
1976
1977 D = [D, struct(...
1978 'DesName','One way Anova (with constant)',...
1979 'n', [Inf Inf 1 1], 'sF',{{'repl','group','',''}},...
1980 'Hform', 'I(:,2),''-'',''group''',...
1981 'Bform', 'I(:,3),''-'',''\mu''',...
1982 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
1983 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
1984 'iGloNorm',9,'iGC',12,...
1985 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
1986 'b',struct('aTime',0))];
1987
1988 D = [D, struct(...
1989 'DesName','One way Anova (Within-subjects)',...
1990 'n', [1 Inf Inf 1],'sF',{{'repl','condition','subject',''}},...
1991 'Hform', 'I(:,2),''-'',''cond''',...
1992 'Bform', 'I(:,3),''-'',''subj''',...
1993 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
1994 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
1995 'iGloNorm',9,'iGC',12,...
1996 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
1997 'b',struct('aTime',0))];
1998
1999 D = [D, struct(...
2000 'DesName','Simple regression (correlation)',...
2001 'n', [Inf 1 1 1], 'sF',{{'repl','','',''}},...
2002 'Hform', '[]',...
2003 'Bform', 'I(:,2),''-'',''\mu''',...
2004 'nC',[1,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2005 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
2006 'iGloNorm',9,'iGC',12,...
2007 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
2008 'b',struct('aTime',0))];
2009
2010
2011 D = [D, struct(...
2012 'DesName','Multiple regression',...
2013 'n', [Inf 1 1 1], 'sF',{{'repl','','',''}},...
2014 'Hform', '[]',...
2015 'Bform', '[]',...
2016 'nC',[Inf,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2017 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
2018 'iGloNorm',9,'iGC',12,...
2019 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
2020 'b',struct('aTime',0))];
2021
2022 D = [D, struct(...
2023 'DesName','Multiple regression (with constant)',...
2024 'n', [Inf 1 1 1], 'sF',{{'repl','','',''}},...
2025 'Hform', '[]',...
2026 'Bform', 'I(:,2),''-'',''\mu''',...
2027 'nC',[Inf,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2028 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
2029 'iGloNorm',9,'iGC',12,...
2030 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
2031 'b',struct('aTime',0))];
2032
2033 D = [D, struct(...
2034 'DesName','AnCova',...
2035 'n', [Inf Inf 1 1], 'sF',{{'repl','group','',''}},...
2036 'Hform', 'I(:,2),''-'',''group''',...
2037 'Bform', 'I(:,3),''-'',''\mu''',...
2038 'nC',[0,1],'iCC',{{8,1}},'iCFI',{{1,1}},...
2039 'iGXcalc',[-1,2,3],'iGMsca',[1,-9],'GM',[],...
2040 'iGloNorm',9,'iGC',12,...
2041 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
2042 'b',struct('aTime',0))];
2043
2044 varargout = {D};
2045
2046
2047 case 'desdefs_pet'
2048 %=======================================================================
2049 % - Standard (SPM99) PET/SPECT Design definitions...
2050 %=======================================================================
2051 % D = spm_spm_ui('DesDefs_PET');
2052 % These are the standard PET design definitions...
2053
2054 %-Single subject
2055 %-----------------------------------------------------------------------
2056 D = struct(...
2057 'DesName','Single-subject: conditions & covariates',...
2058 'n', [Inf Inf 1 1], 'sF',{{'repl','condition','',''}},...
2059 'Hform', 'I(:,2),''-'',''cond''',...
2060 'Bform', 'I(:,3),''-'',''\mu''',...
2061 'nC',[Inf,Inf],'iCC',{{[-1,3,8],[-1,8]}},'iCFI',{{[1,3],1}},...
2062 'iGXcalc',[1,2,-3],'iGMsca',[-1,9],'GM',50,...
2063 'iGloNorm',[1,8,9],'iGC',10,...
2064 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2065 'b',struct('aTime',1));
2066
2067 D = [D, struct(...
2068 'DesName','Single-subject: covariates only',...
2069 'n', [Inf 1 1 1], 'sF',{{'repl','','',''}},...
2070 'Hform', '[]',...
2071 'Bform', 'I(:,3),''-'',''\mu''',...
2072 'nC',[Inf,Inf],'iCC',{{[-1,8],[-1,8]}},'iCFI',{{1,1}},...
2073 'iGXcalc',[1,2,-3],'iGMsca',[-1,9],'GM',50,...
2074 'iGloNorm',[1,8,9],'iGC',10,...
2075 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2076 'b',struct('aTime',1))];
2077
2078 %-Multi-subject
2079 %-----------------------------------------------------------------------
2080 D = [D, struct(...
2081 'DesName','Multi-subj: conditions & covariates',...
2082 'n',[Inf Inf Inf 1], 'sF',{{'repl','condition','subject',''}},...
2083 'Hform', 'I(:,2),''-'',''cond''',...
2084 'Bform', 'I(:,3),''-'',''subj''',...
2085 'nC',[Inf,Inf],'iCC',{{[1,3,4,8],[1,4,8]}},'iCFI',{{[1,3,-4],[1,-4]}},...
2086 'iGXcalc',[1,2,-3],'iGMsca',[-4,9],'GM',50,...
2087 'iGloNorm',[4,8,9],'iGC',10,...
2088 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2089 'b',struct('aTime',1))];
2090
2091 D = [D, struct(...
2092 'DesName','Multi-subj: cond x subj interaction & covariates',...
2093 'n',[Inf Inf Inf 1], 'sF',{{'repl','condition','subject',''}},...
2094 'Hform', 'I(:,[3,2]),''-'',{''subj'',''cond''}',...
2095 'Bform', 'I(:,3),''-'',''subj''',...
2096 'nC',[Inf,Inf],'iCC',{{[1,3,4,8],[1,4,8]}},'iCFI',{{[1,3,-4],[1,-4]}},...
2097 'iGXcalc',[1,2,-3],'iGMsca',[-4,9],'GM',50,...
2098 'iGloNorm',[4,8,9],'iGC',10,...
2099 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2100 'b',struct('aTime',1))];
2101
2102 D = [D, struct(...
2103 'DesName','Multi-subj: covariates only',...
2104 'n',[Inf 1 Inf 1], 'sF',{{'repl','','subject',''}},...
2105 'Hform', '[]',...
2106 'Bform', 'I(:,3),''-'',''subj''',...
2107 'nC',[Inf,Inf],'iCC',{{[1,4,8],[1,4,8]}},'iCFI',{{[1,-4],[1,-4]}},...
2108 'iGXcalc',[1,2,-3],'iGMsca',[-4,9],'GM',50,...
2109 'iGloNorm',[4,8:9],'iGC',10,...
2110 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2111 'b',struct('aTime',0))];
2112
2113 %-Multi-group
2114 %-----------------------------------------------------------------------
2115 D = [D, struct(...
2116 'DesName','Multi-group: conditions & covariates',...
2117 'n',[Inf Inf Inf Inf], 'sF',{{'repl','condition','subject','group'}},...
2118 'Hform', 'I(:,[4,2]),''-'',{''stud'',''cond''}',...
2119 'Bform', 'I(:,[4,3]),''-'',{''stud'',''subj''}',...
2120 'nC',[Inf,Inf],'iCC',{{[5:8],[5,7,8]}},'iCFI',{{[1,5,6,-7],[1,5,-7]}},...
2121 'iGXcalc',[1,2,-3],'iGMsca',[-7,9],'GM',50,...
2122 'iGloNorm',[7,8,9],'iGC',10,...
2123 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2124 'b',struct('aTime',1))];
2125
2126 D = [D, struct(...
2127 'DesName','Multi-group: covariates only',...
2128 'n',[Inf 1 Inf Inf], 'sF',{{'repl','','subject','group'}},...
2129 'Hform', '[]',...
2130 'Bform', 'I(:,[4,3]),''-'',{''stud'',''subj''}',...
2131 'nC',[Inf,Inf],'iCC',{{[5,7,8],[5,7,8]}},'iCFI',{{[1,5,-7],[1,5,-7]}},...
2132 'iGXcalc',[1,2,-3],'iGMsca',[-7,9],'GM',50,...
2133 'iGloNorm',[7,8,9],'iGC',10,...
2134 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2135 'b',struct('aTime',0))];
2136
2137 %-Population comparisons
2138 %-----------------------------------------------------------------------
2139 D = [D, struct(...
2140 'DesName',...
2141 'Population main effect: 2 cond''s, 1 scan/cond (paired t-test)',...
2142 'n',[1 2 Inf 1], 'sF',{{'','condition','subject',''}},...
2143 'Hform', 'I(:,2),''-'',''cond''',...
2144 'Bform', 'I(:,3),''-'',''\mu''',...
2145 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2146 'iGXcalc',[1,2,-3],'iGMsca',[-1,9],'GM',50,...
2147 'iGloNorm',[8,9],'iGC',10,...
2148 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2149 'b',struct('aTime',0))];
2150
2151 D = [D, struct(...
2152 'DesName',...
2153 'Dodgy population main effect: >2 cond''s, 1 scan/cond',...
2154 'n',[1 Inf Inf 1], 'sF',{{'','condition','subject',''}},...
2155 'Hform', 'I(:,2),''-'',''cond''',...
2156 'Bform', 'I(:,3),''-'',''\mu''',...
2157 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2158 'iGXcalc',[1,2,-3],'iGMsca',[-1,9],'GM',50,...
2159 'iGloNorm',[8,9],'iGC',10,...
2160 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2161 'b',struct('aTime',0))];
2162
2163 D = [D, struct(...
2164 'DesName','Compare-populations: 1 scan/subject (two sample t-test)',...
2165 'n',[Inf 2 1 1], 'sF',{{'subject','group','',''}},...
2166 'Hform', 'I(:,2),''-'',''group''',...
2167 'Bform', 'I(:,3),''-'',''\mu''',...
2168 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2169 'iGXcalc',[1,2,-3],'iGMsca',[-1,9],'GM',50,...
2170 'iGloNorm',[8,9],'iGC',10,...
2171 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2172 'b',struct('aTime',0))];
2173
2174 D = [D, struct(...
2175 'DesName','Compare-populations: 1 scan/subject (AnCova)',...
2176 'n',[Inf 2 1 1], 'sF',{{'subject','group','',''}},...
2177 'Hform', 'I(:,2),''-'',''group''',...
2178 'Bform', 'I(:,3),''-'',''\mu''',...
2179 'nC',[0,Inf],'iCC',{{8,1}},'iCFI',{{1,1}},...
2180 'iGXcalc',[1,2,-3],'iGMsca',[-1,9],'GM',50,...
2181 'iGloNorm',[1,8,9],'iGC',10,...
2182 'M_',struct('T',[0,0.8*sqrt(-1)],'I',0,'X',0),...
2183 'b',struct('aTime',0))];
2184
2185 %-The Full Monty!
2186 %-----------------------------------------------------------------------
2187 D = [D, struct(...
2188 'DesName','The Full Monty...',...
2189 'n',[Inf Inf Inf Inf], 'sF',{{'repl','cond','subj','group'}},...
2190 'Hform', 'I(:,[4,2]),''-'',{''stud'',''cond''}',...
2191 'Bform', 'I(:,[4,3]),''-'',{''stud'',''subj''}',...
2192 'nC',[Inf,Inf],'iCC',{{[1:8],[1:8]}},'iCFI',{{[1:7],[1:7]}},...
2193 'iGXcalc',[1,2,3],'iGMsca',[1:7],'GM',50,...
2194 'iGloNorm',[1:9],'iGC',[1:11],...
2195 'M_',struct('T',[-Inf,0,0.8*sqrt(-1)],'I',Inf,'X',Inf),...
2196 'b',struct('aTime',1))];
2197
2198
2199 varargout = {D};
2200
2201 case 'desdefs_pet96'
2202 %=======================================================================
2203 % - SPM96 PET/SPECT Design definitions...
2204 %=======================================================================
2205 % D = spm_spm_ui('DesDefs_PET96');
2206
2207 %-Single subject
2208 %-----------------------------------------------------------------------
2209 D = struct(...
2210 'DesName','SPM96:Single-subject: replicated conditions',...
2211 'n', [Inf Inf 1 1], 'sF',{{'repl','condition','',''}},...
2212 'Hform', 'I(:,2),''-'',''cond''',...
2213 'Bform', 'I(:,3),''-'',''\mu''',...
2214 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2215 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2216 'iGloNorm',[1,8,9],'iGC',10,...
2217 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2218 'b',struct('aTime',0));
2219
2220 D = [D, struct(...
2221 'DesName','SPM96:Single-subject: replicated conditions & covariates',...
2222 'n', [Inf Inf 1 1], 'sF',{{'repl','condition','',''}},...
2223 'Hform', 'I(:,2),''-'',''cond''',...
2224 'Bform', 'I(:,3),''-'',''\mu''',...
2225 'nC',[Inf,Inf],'iCC',{{1,1}},'iCFI',{{1,1}},...
2226 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2227 'iGloNorm',[1,8,9],'iGC',10,...
2228 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2229 'b',struct('aTime',0))];
2230
2231 D = [D, struct(...
2232 'DesName','SPM96:Single-subject: covariates only',...
2233 'n', [Inf 1 1 1], 'sF',{{'repl','','',''}},...
2234 'Hform', '[]',...
2235 'Bform', 'I(:,3),''-'',''\mu''',...
2236 'nC',[Inf,Inf],'iCC',{{1,1}},'iCFI',{{1,1}},...
2237 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2238 'iGloNorm',[1,8,9],'iGC',10,...
2239 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2240 'b',struct('aTime',0))];
2241
2242 %-Multi-subject
2243 %-----------------------------------------------------------------------
2244 D = [D, struct(...
2245 'DesName','SPM96:Multi-subject: different conditions',...
2246 'n', [1 Inf Inf 1], 'sF',{{'','condition','subject',''}},...
2247 'Hform', 'I(:,2),''-'',''scancond''',...
2248 'Bform', 'I(:,3),''-'',''subj''',...
2249 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2250 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2251 'iGloNorm',[1,4,8,9],'iGC',10,...
2252 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2253 'b',struct('aTime',0))];
2254
2255 D = [D, struct(...
2256 'DesName','SPM96:Multi-subject: replicated conditions',...
2257 'n',[Inf Inf Inf 1], 'sF',{{'repl','condition','subject',''}},...
2258 'Hform', 'I(:,2),''-'',''cond''',...
2259 'Bform', 'I(:,3),''-'',''subj''',...
2260 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2261 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2262 'iGloNorm',[1,4,8,9],'iGC',10,...
2263 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2264 'b',struct('aTime',0))];
2265
2266 D = [D, struct(...
2267 'DesName','SPM96:Multi-subject: different conditions & covariates',...
2268 'n', [1 Inf Inf 1], 'sF',{{'','condition','subject',''}},...
2269 'Hform', 'I(:,2),''-'',''cond''',...
2270 'Bform', 'I(:,3),''-'',''subj''',...
2271 'nC',[Inf,Inf],'iCC',{{1,1}},'iCFI',{{[1,4],[1,4]}},...
2272 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2273 'iGloNorm',[1,4,8,9],'iGC',10,...
2274 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2275 'b',struct('aTime',0))];
2276
2277 D = [D, struct(...
2278 'DesName','SPM96:Multi-subject: replicated conditions & covariates',...
2279 'n',[Inf Inf Inf 1], 'sF',{{'repl','condition','subject',''}},...
2280 'Hform', 'I(:,2),''-'',''condition''',...
2281 'Bform', 'I(:,3),''-'',''subj''',...
2282 'nC',[Inf,Inf],'iCC',{{1,1}},'iCFI',{{[1,3,4],[1,4]}},...
2283 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2284 'iGloNorm',[1,4,8,9],'iGC',10,...
2285 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2286 'b',struct('aTime',0))];
2287
2288 D = [D, struct(...
2289 'DesName','SPM96:Multi-subject: covariates only',...
2290 'n',[Inf 1 Inf 1], 'sF',{{'repl','','subject',''}},...
2291 'Hform', '[]',...
2292 'Bform', 'I(:,3),''-'',''subj''',...
2293 'nC',[Inf,Inf],'iCC',{{[1,4,8],[1,4,8]}},'iCFI',{{[1,4],[1,4]}},...
2294 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2295 'iGloNorm',[1,4,8,9],'iGC',10,...
2296 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2297 'b',struct('aTime',0))];
2298
2299 %-Multi-study
2300 %-----------------------------------------------------------------------
2301 D = [D, struct(...
2302 'DesName','SPM96:Multi-study: different conditions',...
2303 'n',[1 Inf Inf Inf], 'sF',{{'','cond','subj','study'}},...
2304 'Hform', 'I(:,[4,2]),''-'',{''study'',''cond''}',...
2305 'Bform', 'I(:,[4,3]),''-'',{''study'',''subj''}',...
2306 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2307 'iGXcalc',3,'iGMsca',[1,5,9],'GM',50,...
2308 'iGloNorm',[1,5,7,8,9],'iGC',10,...
2309 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2310 'b',struct('aTime',0))];
2311
2312 D = [D, struct(...
2313 'DesName','SPM96:Multi-study: replicated conditions',...
2314 'n',[Inf Inf Inf Inf], 'sF',{{'repl','cond','subj','study'}},...
2315 'Hform', 'I(:,[4,2]),''-'',{''study'',''condition''}',...
2316 'Bform', 'I(:,[4,3]),''-'',{''study'',''subj''}',...
2317 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2318 'iGXcalc',3,'iGMsca',[1,5,9],'GM',50,...
2319 'iGloNorm',[1,5,7,8,9],'iGC',10,...
2320 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2321 'b',struct('aTime',0))];
2322
2323 D = [D, struct(...
2324 'DesName','SPM96:Multi-study: different conditions & covariates',...
2325 'n',[1 Inf Inf Inf], 'sF',{{'','cond','subj','study'}},...
2326 'Hform', 'I(:,[4,2]),''-'',{''study'',''cond''}',...
2327 'Bform', 'I(:,[4,3]),''-'',{''study'',''subj''}',...
2328 'nC',[Inf,Inf],'iCC',{{1,1}},'iCFI',{{[1,5,6,7],[1,5,7]}},...
2329 'iGXcalc',3,'iGMsca',[1,5,9],'GM',50,...
2330 'iGloNorm',[1,5,7,8,9],'iGC',10,...
2331 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2332 'b',struct('aTime',0))];
2333
2334 D = [D, struct(...
2335 'DesName','SPM96:Multi-study: replicated conditions & covariates',...
2336 'n',[Inf Inf Inf Inf], 'sF',{{'','cond','subj','study'}},...
2337 'Hform', 'I(:,[4,2]),''-'',{''study'',''condition''}',...
2338 'Bform', 'I(:,[4,3]),''-'',{''study'',''subj''}',...
2339 'nC',[Inf,Inf],'iCC',{{1,1}},'iCFI',{{[1,5,6,7],[1,5,7]}},...
2340 'iGXcalc',3,'iGMsca',[1,5,9],'GM',50,...
2341 'iGloNorm',[1,5,7,8,9],'iGC',10,...
2342 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2343 'b',struct('aTime',0))];
2344
2345 D = [D, struct(...
2346 'DesName','SPM96:Multi-study: covariates only',...
2347 'n',[Inf 1 Inf Inf], 'sF',{{'repl','','subj','study'}},...
2348 'Hform', '[]',...
2349 'Bform', 'I(:,[4,3]),''-'',{''study'',''subj''}',...
2350 'nC',[Inf,Inf],'iCC',{{1,1}},'iCFI',{{[1,5,7],[1,5,7]}},...
2351 'iGXcalc',3,'iGMsca',[1,5,9],'GM',50,...
2352 'iGloNorm',[1,5,7,8,9],'iGC',10,...
2353 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2354 'b',struct('aTime',0))];
2355
2356 %-Group comparisons
2357 %-----------------------------------------------------------------------
2358 D = [D, struct(...
2359 'DesName','SPM96:Compare-groups: 1 scan per subject',...
2360 'n',[Inf Inf 1 1], 'sF',{{'subject','group','',''}},...
2361 'Hform', 'I(:,2),''-'',''group''',...
2362 'Bform', '[]',...
2363 'nC',[0,0],'iCC',{{8,8}},'iCFI',{{1,1}},...
2364 'iGXcalc',3,'iGMsca',[1,9],'GM',50,...
2365 'iGloNorm',[1,8,9],'iGC',10,...
2366 'M_',struct('T',[0.8*sqrt(-1)],'I',0,'X',0),...
2367 'b',struct('aTime',0))];
2368
2369 varargout = {D};
2370
2371
2372 otherwise
2373 %=======================================================================
2374 % - U N K N O W N A C T I O N
2375 %=======================================================================
2376 warning(['Illegal Action string: ',Action])
2377
2378
2379 %=======================================================================
2380 % - E N D
2381 %=======================================================================
2382 end
2383
2384
2385
2386
2387 %=======================================================================
2388 %- S U B - F U N C T I O N S
2389 %=======================================================================
2390
2391 function str = sf_estrrep(str,srstr)
2392 %=======================================================================
2393 for i = 1:size(srstr,1)
2394 str = strrep(str,srstr{i,1},srstr{i,2});
2395 end
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.