The shape of the T1 image and the shape of the electric field are different
-
but are you using a slice field viewer to show the interpolated MRI slice? If not you basically are looking at the original MRI, with different grid and data ordering.
-
I sent you code (it can also be done in GUI) above to interpolate the T1w image onto the E-field/simulation grid. If you do that you can export it in the same format as you export the E-field (not as a nii.gz file, since the simulation grid is rectilinear which is not supported by nifti files).
-
@bryn Is the following code correct? I'm not sure if the input is correct.
inputs1 = [model_to_grid_filter.Outputs[""]] field_data_text_exporter1 = analysis.exporters.FieldDataTextExporter(inputs=inputs1) field_data_text_exporter1.FileName = output_file1 field_data_text_exporter1.UpdateAttributes() document.AllAlgorithms.Add(field_data_text_exporter1) field_data_text_exporter1.Update(overwrite=True)
-
this does not include the interpolation...
to access an output of an analysis algorithm you can use named outputs or indexed outputs, in your snippet above it may be easier to use the index '0'.
inputs1 = [model_to_grid_filter.Outputs[0]]
-
what does your code look like? I create the pipeline in the GUI and it seems to run fine for me (v9.0.0). The "To Python" function yields
# This script was auto-generated by Sim4Life version 9.0.1 import numpy import s4l_v1.analysis as analysis import s4l_v1.document as document import s4l_v1.model as model import s4l_v1.units as units from s4l_v1 import ReleaseVersion from s4l_v1 import Unit try: # Define the version to use for default values ReleaseVersion.set_active(ReleaseVersion.version9_0) # Creating the analysis pipeline # Adding a new ModelToGridFilter inputs = [] model_to_grid_filter = analysis.core.ModelToGridFilter(inputs=inputs) model_to_grid_filter.Name = "IXI025-Guys-0852-T1" model_to_grid_filter.Entity = model.AllEntities()["IXI025-Guys-0852-T1"] model_to_grid_filter.UpdateAttributes() document.AllAlgorithms.Add(model_to_grid_filter) # Adding a new SimulationExtractor simulation = document.AllSimulations["EM"] simulation_extractor = simulation.Results() # Adding a new EmSensorExtractor em_sensor_extractor = simulation_extractor["Overall Field"] em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All" document.AllAlgorithms.Add(em_sensor_extractor) # Adding a new FieldInterpolationFilter inputs = [model_to_grid_filter.Outputs[0], em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]] field_interpolation_filter = analysis.core.FieldInterpolationFilter(inputs=inputs) field_interpolation_filter.UpdateAttributes() document.AllAlgorithms.Add(field_interpolation_filter) # Adding a new FieldDataTextExporter inputs = [field_interpolation_filter.Outputs[""]] field_data_text_exporter = analysis.exporters.FieldDataTextExporter(inputs=inputs) field_data_text_exporter.FileName = u"D:\\temp\\ExportedFieldData-T1w.txt" field_data_text_exporter.UpdateAttributes() document.AllAlgorithms.Add(field_data_text_exporter) except Exception as exc: import traceback traceback.print_exc() # Reset active version to default ReleaseVersion.reset() raise(exc)