Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,10 @@ def _determine_new_nifti_assembly_rel_path(self):

# determine NIfTI file name
new_nifti_name = self._construct_nifti_filename(file_bids_entities_dict)
while os.path.exists(os.path.join(self.data_dir, new_nifti_rel_dir, new_nifti_name)):
already_inserted_filenames = self.imaging_obj.get_list_of_files_already_inserted_for_tarchive_id(
self.dicom_archive_obj.tarchive_info_dict["TarchiveID"]
)
while new_nifti_name in already_inserted_filenames:
file_bids_entities_dict['run'] += 1
new_nifti_name = self._construct_nifti_filename(file_bids_entities_dict)

Expand Down
20 changes: 20 additions & 0 deletions python/lib/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,26 @@ def determine_intended_for_field_for_fmap_json_files(self, tarchive_id):

return sorted_fmap_files_dict

def get_list_of_files_already_inserted_for_tarchive_id(self, tarchive_id):
"""
Get the list of filenames already inserted for a given TarchiveID.

:param tarchive_id: the Tarchive ID to process
:type tarchive_id: int

:return: a list with file names already inserted in the files table for TarchiveID
:rtype: list
"""

# get list files from a given tarchive ID
results = self.files_db_obj.get_files_inserted_for_tarchive_id(tarchive_id)

files_list = []
for entry in results:
files_list.append(os.path.basename(entry['File']))

return files_list

def get_list_of_fmap_files_sorted_by_acq_time(self, files_list):
"""
Get the list of fieldmap acquisitions that requires the IntendedFor field in their JSON file.
Expand Down