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