@@ -243,9 +243,10 @@ def make_problem(project: ratapi.Project) -> ProblemDefinition:
243243 contrast_background_param = []
244244
245245 if background .type == TypeOptions .Data :
246- contrast_background_param .append (project .data .index (background .source , True ))
246+ # Background data is appended to contrast data so empty index
247+ contrast_background_param .append (np .array ([]))
247248 if background .value_1 != "" :
248- contrast_background_param . append ( project .background_parameters .index (background .value_1 ) )
249+ contrast_background_param [ - 1 ] = project .background_parameters .index (background .value_1 )
249250 # If we are using a data background, we add the background data to the contrast data
250251 data = append_data_background (data , project .data [background .source ].data )
251252
@@ -492,7 +493,7 @@ def check_indices(problem: ProblemDefinition) -> None:
492493
493494 source_param_lists = {
494495 "constant" : "backgroundParams" ,
495- "data" : "data " ,
496+ "data" : "backgroundParams " ,
496497 "function" : "customFiles" ,
497498 }
498499
@@ -501,11 +502,13 @@ def check_indices(problem: ProblemDefinition) -> None:
501502
502503 # check source param is in range of the relevant parameter list
503504 param_list = getattr (problem , source_param_lists [background_type ])
504- source_index = background_data [0 ]
505- if not 0 < source_index <= len (param_list ):
505+ # For data, background data is appended to the contrast data so first index could
506+ # either be empty or be the index of an offset.
507+ first_index = background_data [0 ]
508+ if np .size (first_index ) > 0 and not 0 < first_index <= len (param_list ):
506509 raise IndexError (
507510 f'Entry { i } of contrastBackgroundParams has type "{ background_type } " '
508- f"and source index { source_index } , "
511+ f"and source index { first_index } , "
509512 f'which is outside the range of "{ source_param_lists [background_type ]} ".'
510513 )
511514
0 commit comments