Я использую niilearn для предварительной обработки изображения МРТ. Но он не работает, поскольку имя создаваемого файла — rest_mcf.nii_mean_reg.nii. Как видите, расширение .nii появляется два раза, а не один. Этот файл должен называться rest_mcf_mean_reg.nii. Поскольку имя файла неверное, мой рабочий процесс не продолжается.
Я прикрепил код ниже. Почему возникает эта ошибка? Что делать, чтобы этого больше не повторилось?
func_template = 'cocaine_dataset/sub-{subject_id}/func/sub-{subject_id}_task-{task_name}.nii.gz'
templates = {
'func': func_template,
}
# Infosource: Iterate over subject and task
infosource = Node(IdentityInterface(fields=['subject_id', 'task_name']),
name="infosource")
infosource.iterables = [('subject_id', subject_list),
('task_name', task_list)]
# SelectFiles: Template-based file selection
selectfiles = Node(SelectFiles(templates), name="selectfiles")
# MCFLIRT: Motion Correction (realignment)
realign = Node(MCFLIRT(
mean_vol=True, # Create a mean image for reference
save_plots=True, # Save motion correction plots
output_type='NIFTI', # Save output as NIFTI
out_file='rest_mcf.nii'), name="realign")
# DataSink: Organize outputs
datasink = Node(DataSink(base_directory=experiment_dir,
container=output_dir),
name="datasink")
# Define substitutions for datasink output
substitutions = [
('_subject_id_', 'sub-'),
('_task_name_', 'task-'),
('.nii_mean_reg.nii', '_mean.nii.gz'), # Handle the double extension
('_mcf.nii.gz', '_mcf'), # Remove additional .nii.gz
('.mat', '.par'),
('_flirt', '') # Remove unwanted suffix
]
datasink.inputs.substitutions = substitutions
# Create the workflow
realignment_wf = Workflow(name="realignment")
realignment_wf.base_dir = opj(experiment_dir, working_dir)
# Connect the nodes
realignment_wf.connect([
(infosource, selectfiles, [('subject_id', 'subject_id'),
('task_name', 'task_name')]),
(selectfiles, realign, [('func', 'in_file')]),
(realign, datasink, [('out_file', 'realignment.@realigned'),
('par_file', 'realignment.@motion_parameters')])
])
# Run the workflow
realignment_wf.run('MultiProc', plugin_args={'n_procs': 1})
Подробнее здесь: https://stackoverflow.com/questions/792 ... per-output
Рабочий процесс Niilearn дает неправильный результат ⇐ Python
Программы на Python
-
Anonymous
1732401440
Anonymous
Я использую niilearn для предварительной обработки изображения МРТ. Но он не работает, поскольку имя создаваемого файла — rest_mcf.nii_mean_reg.nii. Как видите, расширение .nii появляется два раза, а не один. Этот файл должен называться rest_mcf_mean_reg.nii. Поскольку имя файла неверное, мой рабочий процесс не продолжается.
Я прикрепил код ниже. Почему возникает эта ошибка? Что делать, чтобы этого больше не повторилось?
func_template = 'cocaine_dataset/sub-{subject_id}/func/sub-{subject_id}_task-{task_name}.nii.gz'
templates = {
'func': func_template,
}
# Infosource: Iterate over subject and task
infosource = Node(IdentityInterface(fields=['subject_id', 'task_name']),
name="infosource")
infosource.iterables = [('subject_id', subject_list),
('task_name', task_list)]
# SelectFiles: Template-based file selection
selectfiles = Node(SelectFiles(templates), name="selectfiles")
# MCFLIRT: Motion Correction (realignment)
realign = Node(MCFLIRT(
mean_vol=True, # Create a mean image for reference
save_plots=True, # Save motion correction plots
output_type='NIFTI', # Save output as NIFTI
out_file='rest_mcf.nii'), name="realign")
# DataSink: Organize outputs
datasink = Node(DataSink(base_directory=experiment_dir,
container=output_dir),
name="datasink")
# Define substitutions for datasink output
substitutions = [
('_subject_id_', 'sub-'),
('_task_name_', 'task-'),
('.nii_mean_reg.nii', '_mean.nii.gz'), # Handle the double extension
('_mcf.nii.gz', '_mcf'), # Remove additional .nii.gz
('.mat', '.par'),
('_flirt', '') # Remove unwanted suffix
]
datasink.inputs.substitutions = substitutions
# Create the workflow
realignment_wf = Workflow(name="realignment")
realignment_wf.base_dir = opj(experiment_dir, working_dir)
# Connect the nodes
realignment_wf.connect([
(infosource, selectfiles, [('subject_id', 'subject_id'),
('task_name', 'task_name')]),
(selectfiles, realign, [('func', 'in_file')]),
(realign, datasink, [('out_file', 'realignment.@realigned'),
('par_file', 'realignment.@motion_parameters')])
])
# Run the workflow
realignment_wf.run('MultiProc', plugin_args={'n_procs': 1})
Подробнее здесь: [url]https://stackoverflow.com/questions/79218976/niilearn-workflow-giving-improper-output[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия