-
Notifications
You must be signed in to change notification settings - Fork 532
N4BiasFieldCorrection output! #2806
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
Comments
Hi, could you provide the code you're running? |
This is the code I am running: import copy |
Can you run: res = n4.run()
print(res.outputs) |
Great! It worked. AttributeError: 'NoneType' object has no attribute 'outputs'. I also tried "res.output_image" as an output of N4BiasFieldCorrection. Thanks for your help! |
Sorry, I don't understand the question. What are you trying to do? |
I want to create a node doing bias field correction like this:
While function biasfield_correct has been defined as follows:
putting this node in my workflow, I have the error: "res.output_image" as an output of N4BiasFieldCorrection! |
You can wrap the interface in a from nipype.pipeline import engine as pe
from nipype.interfaces import ants
bias = pe.Node(
N4BiasFieldCorrection(
dimension=3,
bspline_fitting_distance=300,
shrink_factor=3,
n_iterations=[50, 50, 30, 20],
convergence_threshold=1e-6),
name='bias_correction') Then you would connect to res = bias.run()
res.outputs should produce essentially the same results as running the interface directly, but all of the outputs should be contained in the
I'm not sure how this would arise from what you've posted. |
Hi, I have another problem with input stream, Selectfile node when I want to run the whole pipeline. Following is my pipeline: #1: import appropriate modules
import nipype.pipeline.engine as pe # the workflow and node wrappers
from nipype.interfaces.utility import IdentityInterface
from nipype.interfaces.ants import N4BiasFieldCorrection
from nipype.interfaces.io import SelectFiles, DataSink
import os
#2: Specify variables
base_dir = "/home/masoomeh/MR_Preprocess/"
output_dir = os.path.join(os.path.dirname(base_dir), "out")
in_file = "/home"
subject_id = ["Brats17_CBICA_AQA_1"]
#3: Specify nodes
anat_input = pe.Node(IdentityInterface(fields=in_file, mandatory_inputs=True),name="anat_input")
biascor = pe.Node(N4BiasFieldCorrection(input_image = in_file,
dimension=3,
bspline_fitting_distance=300,
shrink_factor=3,
n_iterations=[50, 50, 30, 20],
convergence_threshold=1e-6),
name = "bias_correction")
#4: Create the workflow object, specify workflow
wf = pe.Workflow(name='preproc')
wf.base_dir = '.'
#5: Input and output stream
templates = {'anat': 'data/{subject_id}/struct.nii'}
selectfiles = pe.Node(SelectFiles(templates,
base_directory=base_dir), name="selectfiles")
datasink = pe.Node(DataSink(parameterization=False), name="datasink")
datasink.inputs.base_directory = "/home/masoomeh/MR_Preprocess/"
datasink.inputs.container = output_dir
substitutions = [('_subject_id_', '')]
datasink.inputs.substitutions = substitutions
infosource = pe.Node(IdentityInterface(fields=["subject_id"]), name="infosource")
wf.connect([
# Connect SelectFiles and DataSink to the workflow
(infosource, selectfiles, [("subject_id", "subject_id")]),
(selectfiles, anat_input, [("anat", "in_file")]),
(anat_input, biascor, [("in_file", "input_image")]),
(anat_input, datasink, [("in_file", "output_anat")]),
# input to datasink
(biascor, datasink , [("output_image", "output_bias")]),
])
#6. run worflow
wf.write_graph()
wf.run() Running the code, I have this error:
This is for only one data, while I want to extend it for more data. Thanks in advance for your help! |
anat_input = pe.Node(IdentityInterface(fields=in_file, mandatory_inputs=True),name="anat_input")
biascor = pe.Node(N4BiasFieldCorrection(input_image = in_file, Again, same issue, but I think it gets overridden by your infosource = pe.Node(IdentityInterface(fields=["subject_id"]), name="infosource") It doesn't appear you ever supply a subject ID to I assume your datasink is okay, but it's really impossible to say without running. |
Now I get the iterable idea and my pipeline is working quite well for whole subjects each includes different modalities. infosource = pe.Node(IdentityInterface(fields=["subject_id","session_id"]), name="infosource") infosource.iterables = [("subject_id", subject_id), templates = {'anat': 'data/{subject_id}/{session_id}.nii'} wf.connect([ Thank you very much for all your help! |
No problem! |
Hello , @effigies
|
this usually happens if the command is not available in your path. try opening a terminal and see if also if you are using tools like spyder or pycharm, you will need to ensure that shell variables are exposed. or if you are familiar with docker, you can create a docker image with ants and nipype (using neurodocker) and run the script you are trying to run within the docker instance. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Hi,
I am trying to use N4BiasFieldCorrection function imported from nipype.interfaces.ants to preprocess my MRI data. I am running the example code you have provided and I have this line :
" N4BiasFieldCorrection --bspline-fitting [ 300 ] -d 3 --input-image /home/masoomeh/MR_Preprocess/data/Brats17_CBICA_AQA_1/Normalized_Brats17_CBICA_AQA_1_flair.nii --convergence [ 50x50x30x20 ] --output /home/masoomeh/MR_Preprocess/data/Brats17_CBICA_AQA_1/corrected.nii --shrink-factor 3'
"
But the problem is that there is no output on my disk!
I'll be grateful for any debugging advice or other insight.
Platform details:
Execution environment
Python 3.5
The text was updated successfully, but these errors were encountered: