@@ -1030,7 +1030,7 @@ def options(self, options: dict):
10301030 def plugins (self ) -> Plugins :
10311031 """The plugin dictionaries with their options"""
10321032
1033- return self ._data ['Options' ][ 'plugins' ]
1033+ return self ._data ['Options' ]. get ( 'plugins' , [])
10341034
10351035 @plugins .setter
10361036 def plugins (self , plugins : Plugins ):
@@ -1170,11 +1170,20 @@ def check_template(self) -> bool:
11701170 :return: True if the template bidsmap is valid, otherwise False
11711171 """
11721172
1173- valid = True
1174- ignoretypes = self .options .get ('ignoretypes' , [])
1175- bidsignore = self .options .get ('bidsignore' , [])
1173+ # Check the presence of the bidsmap Options
1174+ if 'Options' not in self ._data :
1175+ LOGGER .error ('The template bidsmap has no "Options" section' )
1176+ return False
1177+ if 'bidscoin' not in self ._data ['Options' ]:
1178+ LOGGER .error ('The template bidsmap has no "bidscoin" options' )
1179+ return False
1180+ if 'plugins' not in self ._data ['Options' ]:
1181+ LOGGER .error ('The template bidsmap contains no "plugins"' )
1182+ return False
11761183
11771184 # Check all the datatypes in the bidsmap
1185+ ignoretypes = self .options .get ('ignoretypes' , [])
1186+ bidsignore = self .options .get ('bidsignore' , [])
11781187 LOGGER .verbose ('Checking the template bidsmap datatypes:' )
11791188 for dataformat in self .dataformats :
11801189 for datatype in dataformat .datatypes :
@@ -1190,14 +1199,16 @@ def check_template(self) -> bool:
11901199 re .compile (str (val ))
11911200 except re .error :
11921201 LOGGER .warning (f"Invalid regex pattern in the { key } value '{ val } ' in: { runitem } \n This may cause run-matching errors unless '{ val } ' is a literal attribute value" )
1202+ if datatypesuffixes == ['events' ]: # Ugly work-around for sparse events2bids Presentation mappings
1203+ continue
11931204 for typegroup in filerules .get (datatype .datatype , {}):
11941205 for suffix in filerules [datatype .datatype ][typegroup ].suffixes :
11951206 if not (suffix in datatypesuffixes or suffix in str (bidsignore ) or
11961207 '[DEPRECATED]' in bidsschema .objects .suffixes [suffix ].description or
11971208 '**Change:** Removed from' in bidsschema .objects .suffixes [suffix ].description or
11981209 '**Change:** Replaced by' in bidsschema .objects .suffixes [suffix ].description ):
11991210 LOGGER .info (f"Missing '{ suffix } ' run-item in: bidsmap[{ dataformat } ][{ datatype } ] (NB: this may perhaps be fine / a deprecated item)" )
1200- # valid = False # TODO: Fix this for sparse events2bids mappings
1211+ valid = False
12011212
12021213 # Validate against the json schema
12031214 with (templatefolder / 'schema.json' ).open ('r' ) as stream :
0 commit comments