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