|
193 | 193 |
|
194 | 194 |
|
195 | 195 | %% Deal with backgrounds and resolutions |
196 | | -backgroundActions = zeros(1, length(inputStruct.contrastBackgrounds)); |
197 | | -for i = 1:length(inputStruct.contrastBackgrounds) |
198 | | - |
199 | | - if strcmpi(inputStruct.contrastBackgroundActions{i}, actions.Add) |
200 | | - backgroundActions(i) = 1; |
201 | | - else |
202 | | - backgroundActions(i) = 2; |
203 | | - end |
204 | | - |
205 | | -end |
| 196 | +% backgroundActions = zeros(1, length(inputStruct.contrastBackgrounds)); |
| 197 | +% for i = 1:length(inputStruct.contrastBackgrounds) |
| 198 | +% |
| 199 | +% if strcmpi(inputStruct.contrastBackgroundActions{i}, actions.Add) |
| 200 | +% backgroundActions(i) = 1; |
| 201 | +% else |
| 202 | +% backgroundActions(i) = 2; |
| 203 | +% end |
| 204 | +% |
| 205 | +% end |
206 | 206 |
|
207 | 207 | % Convert contrastBackgrounds to custom file/parameter indices |
208 | | -contrastBackgrounds = inputStruct.contrastBackgrounds; |
209 | | -backgroundTypes = inputStruct.backgroundTypes; |
210 | | - |
211 | | -backgroundParamNames = inputStruct.backgroundParamNames; |
| 208 | +numContrastBackgrounds = length(inputStruct.contrastBackgrounds); |
212 | 209 |
|
213 | | -contrastBackgroundParams = cell(1, length(contrastBackgrounds)); |
214 | | -contrastBackgroundTypes = cell(1, length(contrastBackgrounds)); |
| 210 | +contrastBackgroundParams = cell(1, numContrastBackgrounds); |
| 211 | +contrastBackgroundTypes = cell(1, numContrastBackgrounds); |
215 | 212 |
|
216 | | -for i = 1:length(contrastBackgrounds) |
| 213 | +for i = 1:numContrastBackgrounds |
217 | 214 | % Check the type of the background that each contrast is pointing to. |
218 | | - thisBack = contrastBackgrounds(i); % Which background |
219 | | - backgroundType = backgroundTypes{thisBack}; % What type is it? |
220 | | - contrastBackgroundTypes{i} = backgroundType; |
| 215 | + thisBack = inputStruct.contrastBackgrounds(i); % Which background |
| 216 | + contrastBackgroundTypes{i} = inputStruct.backgroundTypes{thisBack}; % What type is it? |
221 | 217 |
|
222 | | - switch backgroundType |
| 218 | + switch contrastBackgroundTypes{i} |
223 | 219 |
|
224 | 220 | case allowedTypes.Constant.value |
225 | 221 | % Background is a backgroundParam, the name of which should |
226 | 222 | % be in the first column of backgroundValues |
227 | 223 |
|
228 | 224 | % Find which backgroundParam this is, and set contrastBackgroundParams to this number |
229 | | - contrastBackgroundParams{i} = find(strcmpi(inputStruct.backgroundValues{thisBack,1}, backgroundParamNames)); |
| 225 | + contrastBackgroundParams{i} = find(strcmpi(inputStruct.backgroundValues{thisBack,1}, inputStruct.backgroundParamNames)); |
230 | 226 |
|
231 | 227 | case allowedTypes.Data.value |
232 | 228 | % Background is in a datafile. |
|
255 | 251 | contrastData = insertDataBackgroundIntoContrastData(contrastData,backgroundData); |
256 | 252 | problemCells{2}(i) = contrastData; |
257 | 253 |
|
258 | | - % Also add the index of the data offset to the array... |
259 | | - contrastBackgroundParams{i} = find(strcmpi(backgroundDataOffset,backgroundParamNames)); |
260 | | - |
261 | 254 | % Add the index of the optional data offset to contrastBackgroundParams |
262 | | - if ~isempty(backgroundDataIndex) |
263 | | - contrastBackgroundParams{i} = find(strcmpi(backgroundDataOffset,backgroundParamNames)); |
| 255 | + offsetIndex = find(strcmpi(backgroundDataOffset,inputStruct.backgroundParamNames)); |
| 256 | + if ~isempty(offsetIndex) |
| 257 | + contrastBackgroundParams{i} = offsetIndex; |
264 | 258 | end |
265 | 259 |
|
266 | 260 | case allowedTypes.Function.value |
267 | 261 | % Background is a background function |
| 262 | + % |
| 263 | + % We need the index of the custom file the function is defined |
| 264 | + % in, alongside all of the function parameters. |
268 | 265 |
|
269 | | - % Get the corresponding function name... |
| 266 | + % Get the corresponding function name |
270 | 267 | backgroundFuncfileName = inputStruct.backgroundValues{thisBack,1}; |
271 | 268 |
|
272 | | - % Find the index of this data name in the string array... |
| 269 | + % Find the index of this function name in the custom file array |
273 | 270 | backgroundFunctionIndex = find(strcmp(backgroundFuncfileName,inputStruct.fileNames)); |
274 | 271 |
|
275 | 272 | if isempty(backgroundFunctionIndex) |
|
282 | 279 | functionParams = inputStruct.backgroundValues(thisBack,2:end); |
283 | 280 | numDefined = length(find(~(cellfun(@(x) isequal(x,""),functionParams)))); |
284 | 281 | for n = 1:numDefined |
285 | | - backgroundParamIndex = find(strcmpi(functionParams{n},backgroundParamNames)); |
| 282 | + backgroundParamIndex = find(strcmpi(functionParams{n},inputStruct.backgroundParamNames)); |
286 | 283 | contrastBackgroundParams{i}(n+1) = backgroundParamIndex; |
287 | 284 | end |
288 | 285 |
|
|
369 | 366 | problemStruct.useImaginary = inputStruct.useImaginary; |
370 | 367 | problemStruct.contrastBackgroundParams = contrastBackgroundParams; |
371 | 368 | problemStruct.contrastBackgroundTypes = contrastBackgroundTypes; |
372 | | -problemStruct.contrastBackgroundActions = backgroundActions; |
| 369 | +problemStruct.contrastBackgroundActions = inputStruct.contrastBackgroundActions; |
373 | 370 | problemStruct.contrastQzshifts = inputStruct.contrastQzshifts; |
374 | 371 | problemStruct.contrastScalefactors = inputStruct.contrastScalefactors; |
375 | 372 | problemStruct.contrastBulkIns = inputStruct.contrastBulkIns; |
|
0 commit comments