11import subprocess
2- from pathlib import Path
32
43from loris_utils .path import get_path_stem
54
1211from lib .physio .parameters import insert_physio_file_parameter
1312
1413
15- def create_physio_channels_chunks (env : Env , physio_file : DbPhysioFile , file_path : Path ):
14+ def create_physio_channels_chunks (env : Env , physio_file : DbPhysioFile ):
1615 """
1716 Create the channels chunks for a physiological file based on its source MEG CTF directory.
1817 """
@@ -43,9 +42,12 @@ def create_physio_channels_chunks(env: Env, physio_file: DbPhysioFile, file_path
4342 lib .exitcode .CHUNK_CREATION_FAILURE ,
4443 )
4544
46- chunk_root_dir = get_dataset_chunks_dir_path (env , physio_file )
45+ data_dir_path = get_data_dir_path_config (env )
46+ file_path = data_dir_path / physio_file .path
4747
48- command_parts = [script , str (file_path ), '--destination' , str (chunk_root_dir )]
48+ chunk_root_dir_path = get_dataset_chunks_dir_path (env , physio_file )
49+
50+ command_parts = [script , str (file_path ), '--destination' , str (chunk_root_dir_path )]
4951
5052 try :
5153 log (env , f"Running chunking script with command: { ' ' .join (command_parts )} " )
@@ -63,7 +65,7 @@ def create_physio_channels_chunks(env: Env, physio_file: DbPhysioFile, file_path
6365 lib .exitcode .CHUNK_CREATION_FAILURE ,
6466 )
6567
66- chunk_path = chunk_root_dir / f'{ get_path_stem (physio_file .path )} .chunks'
68+ chunk_path = chunk_root_dir_path / f'{ get_path_stem (physio_file .path )} .chunks'
6769 if not chunk_path .is_dir ():
6870 log_error_exit (
6971 env ,
@@ -89,8 +91,8 @@ def get_dataset_chunks_dir_path(env: Env, physio_file: DbPhysioFile):
8991 # name. The second part of the physiological file path is assumed to be the dataset name.
9092 eeg_chunks_dir_path = get_eeg_chunks_dir_path_config (env )
9193 if eeg_chunks_dir_path is None :
92- data_dir = get_data_dir_path_config (env )
93- eeg_chunks_dir_path = data_dir / physio_file .path .parts [0 ]
94+ data_dir_path = get_data_dir_path_config (env )
95+ eeg_chunks_dir_path = data_dir_path / physio_file .path .parts [0 ]
9496
9597 eeg_chunks_path = eeg_chunks_dir_path / f'{ physio_file .path .parts [1 ]} _chunks'
9698 eeg_chunks_path .mkdir (exist_ok = True )
0 commit comments