@@ -236,3 +236,112 @@ def test_integration_multirun(skip_integration, multi_run_file):
236236 # for run in ['1', '2']:
237237 # assert isfile(join(conversion_path, f'Test2_samefreq_TWOscans_{run}_trigger_time.png'))
238238 assert isfile (join (conversion_path , 'Test2_samefreq_TWOscans.png' ))
239+
240+ def test_integration_gep_onefile (skip_integration , ge_one_gep_file ):
241+ """
242+ Does the integration test for a single GE file
243+ Input file is PPG
244+ """
245+
246+ if skip_integration :
247+ pytest .skip ('Skipping integration test' )
248+
249+ test_path , test_filename = split (ge_one_gep_file )
250+ conversion_path = join (test_path , 'code' , 'conversion' )
251+
252+ phys2bids (filename = test_filename , indir = test_path , outdir = test_path )
253+
254+ # Check that files are generated
255+ for suffix in ['.json' , '.tsv.gz' ]:
256+ assert isfile (join (test_path , test_filename [:- 4 ] + suffix ))
257+
258+ # Check files in extra are generated
259+ for suffix in ['.log' ]:
260+ assert isfile (join (conversion_path , test_filename [:- 4 ] + suffix ))
261+
262+ # Read log file (note that this file is not the logger file)
263+ with open (join (conversion_path , test_filename [:- 4 ] + '.log' )) as log_info :
264+ log_info = log_info .readlines ()
265+
266+ # Check timepoints expected
267+ assert check_string (log_info , 'Timepoints expected' , 'None' , is_num = False )
268+ # Check timepoints found
269+ assert check_string (log_info , 'Timepoints found' , 'None' , is_num = False )
270+ # Check sampling frequency
271+ assert check_string (log_info , 'Sampling Frequency' , '100' )
272+ # Check sampling started
273+ assert check_string (log_info , 'Sampling started' , '30.0000' )
274+ # Check start time
275+ assert check_string (log_info , 'first trigger' , 'Time 0' , is_num = False )
276+
277+ # Checks json file
278+ with open (join (test_path , test_filename [:- 4 ] + '.json' )) as json_file :
279+ json_data = json .load (json_file )
280+
281+ # Compares values in json file with ground truth
282+ assert math .isclose (json_data ['SamplingFrequency' ], 100 )
283+ assert math .isclose (json_data ['StartTime' ], 30.0 )
284+ assert json_data ['Columns' ] == ['time' , 'trigger' , 'cardiac' ]
285+
286+ # Remove generated files
287+ for filename in glob .glob (join (conversion_path , 'phys2bids*' )):
288+ remove (filename )
289+ for filename in glob .glob (join (test_path , test_filename + '*' )):
290+ remove (filename )
291+ shutil .rmtree (conversion_path )
292+
293+
294+ def test_integration_gep_multifile (skip_integration , ge_two_gep_files_ppg ):
295+ """
296+ Does the integration test for a set of two GE files
297+ Input file is PPG with RESP file also in folder
298+ """
299+
300+ if skip_integration :
301+ pytest .skip ('Skipping integration test' )
302+
303+ test_path , test_filename = split (ge_two_gep_files_ppg )
304+ conversion_path = join (test_path , 'code' , 'conversion' )
305+
306+ phys2bids (filename = test_filename , indir = test_path , outdir = test_path )
307+
308+ # Check that files are generated
309+ for suffix in ['.json' , '.tsv.gz' ]:
310+ assert isfile (join (test_path , test_filename [:- 4 ] + '_100Hz' + suffix ))
311+ assert isfile (join (test_path , test_filename [:- 4 ] + '_25Hz' + suffix ))
312+
313+ # Check files in extra are generated
314+ for suffix in ['.log' ]:
315+ assert isfile (join (conversion_path , test_filename [:- 4 ] + '_100Hz' + suffix ))
316+ assert isfile (join (conversion_path , test_filename [:- 4 ] + '_25Hz' + suffix ))
317+
318+ # Read log file (note that this file is not the logger file)
319+ with open (join (conversion_path , test_filename [:- 4 ] + '_100Hz.log' )) as log_info :
320+ log_info = log_info .readlines ()
321+
322+ # Check timepoints expected
323+ assert check_string (log_info , 'Timepoints expected' , 'None' , is_num = False )
324+ # Check timepoints found
325+ assert check_string (log_info , 'Timepoints found' , 'None' , is_num = False )
326+ # Check sampling frequency
327+ assert check_string (log_info , 'Sampling Frequency' , '100' )
328+ # Check sampling started
329+ assert check_string (log_info , 'Sampling started' , '30.0000' )
330+ # Check start time
331+ assert check_string (log_info , 'first trigger' , 'Time 0' , is_num = False )
332+
333+ # Checks json file
334+ with open (join (test_path , test_filename [:- 4 ] + '_100Hz.json' )) as json_file :
335+ json_data = json .load (json_file )
336+
337+ # Compares values in json file with ground truth
338+ assert math .isclose (json_data ['SamplingFrequency' ], 100 )
339+ assert math .isclose (json_data ['StartTime' ], 30.0 )
340+ assert json_data ['Columns' ] == ['time' , 'trigger' , 'cardiac' ]
341+
342+ # Remove generated files
343+ for filename in glob .glob (join (conversion_path , 'phys2bids*' )):
344+ remove (filename )
345+ for filename in glob .glob (join (test_path , test_filename + '*' )):
346+ remove (filename )
347+ shutil .rmtree (conversion_path )
0 commit comments