Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for different extensions in tf_2dunet #1178

Merged
merged 1 commit into from
Dec 3, 2024
Merged
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
35 changes: 20 additions & 15 deletions openfl-workspace/tf_2dunet/src/nii_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,29 @@ def nii_reader(brain_path, task, channels_last=True,

# check that all appropriate files are present
file_root = brain_path.split('/')[-1] + '_'
extension = '.nii.gz'
# check for all possible extensions
extensions = ['.nii.gz', '.nii']

# record files needed
# needed mask files are currntly independent of task
need_files_oneof = list_files(file_root, extension, msk_names)
if normalization != 'modes_together':
need_files_all = list_files(file_root, extension, task_to_img_modes[task])
else:
need_files_all = list_files(file_root, extension, img_modes)

correct_files = np.all([
(reqd in files)
for reqd in need_files_all
]) and np.sum([
(reqd in files)
for reqd in need_files_oneof
]) == 1

need_files_oneof = None
need_files_all = None
for extension in extensions:
need_files_oneof = list_files(file_root, extension, msk_names)
if normalization != 'modes_together':
need_files_all = list_files(file_root, extension, task_to_img_modes[task])
else:
need_files_all = list_files(file_root, extension, img_modes)

correct_files = np.all([
(reqd in files)
for reqd in need_files_all
]) and np.sum([
(reqd in files)
for reqd in need_files_oneof
]) == 1
if correct_files:
break
if not correct_files:
return None, None

Expand Down
Loading