File conversion utilities

Connectivity file from Nifti

The set of connection between two different sites of the brain is contained in a edge file file, that makes it convenient to read in the visualization filter in Paraview.

Generating the edge file is done through the command generate_brain_connectivity_edge_file and requires:

  • the nifti file that can be read with nibabel,
  • the csv file encoding the connections between sites in the brain,
  • the output file.

Warning

This functionality requires the installation of the nibabel python package. Please make sure you followed the Installation procedures.

End-points volume image

The 3D volume containing all the end-points of the connexels can be generated from the command line in the same manner as for the connectivity file. The generated file is in the VTK format.

Warning

Requires nibabel (see above) and VTK (see installation instructions).

Volume image

The 3D volumetric image may be generated from the command line with the command generate_brain_connectivity_volume_file. This call is a wrapper around the function generate_volume_file().

Clustering

A script for performing the clustering of all the edges is provided. This scripts generates a file that can be given to the visualization filter, which makes the exploration of the different edge clusters much faster.

The command to generate the cluster file is generate_brain_connectivity_cluster_file. The command requires:

  • the mesh file,
  • the edge file,
  • the number of desired clusters,
  • the output file

The output file can be given to the visualization filter in Paraview to avoid expensive computations during the visualization.

Warning

Requires nibabel (see above) and VTK (see installation instructions).

Tip

scipy may be used to speed-up the computation of the k-means if installed.

References

utils.generate_from_nifty

Provides tools for constructing intermediate files needed for the visualization.

Note

This file is meant to be installed during the installation of the package as a callable script with several commands.

The functions provided here are:

  • the transformation of a Nifti indicator file to a set of edge coordinates. Those edges will be used by the visualization algorithm
  • the transformation of the Nifti volumetric data to a VTK image that can be rendered inside Paraview.

The edge file requires:

  • a Nifti volume that indicates the end points on a grid, and
  • a CSV file that contains the topology that connects the previous end points. This CSV file should have two columns and a number of rows identical to the number of edges. Each column entry is an index to a coordinate that is extracted from the previous Nifti file. The other columns are ignored.
generate_cluster_file(mesh_file, edge_file, number_of_clusters, output_file, max_iterations=100)

Convenience function for running the clustering on a set of edges

Parameters:
  • mesh_file – the mesh that will be used for centering the data and making it isotropic
  • edge_file – the file containing the edges as computed from generate_edge_file()
  • number_of_cluster – the number of desired clusters
  • output_file – the file in which the results of the clutering will be done
  • max_steps – maximum number of iterations for the kmeans

Note

The plugin will not know if the files and parameters are consistent. If you provide a file name that contains the computation of the centroids for a specific edge file, and the edge file is incorrectly given to the plugin, the plugin will be unable to check.

generate_edge_file(csv_file_path, nifti_edge_file_path, output_file)

Convenience script for creating an edge file

Parameters:
  • nifti_edge_file_path – the path containing the nifti volume indicating the locations of the edge end points
  • csv_file_path – the file containing the topology
  • output_file – the output file in a numpy array format

See also

file_ops.assemble_edges()

generate_edge_volume_file(nifti_edge_file_path, output_file)

Convenience script for creating a volume locating all edges end-points

Parameters:
  • nifti_edge_file_path – the path containing the nifti volume indicating the locations of the edge end points
  • csv_file_path – the file containing the topology
  • output_file – the output file in a VTK file format

See also

file_ops.assemble_edges()

See also

file_ops.save_points_to_vtk_array()

generate_volume_file(nifti_volumetric_file_path, output_file)

Convenience script for creating a VTK compatible volume image file.

utils.generate_plugin_xml

Provides tools for generating the XML Paraview plugins.

generatePythonFilterFromFiles(script_file, output_file, function_name=None)

Generates an XML plugin file for Paraview from Python source file

Parameters:function_name – the name of the function containing the plugin entry point. Defaults to RequestData
generate_plugin_after_install(output_file)

Utility for generating the plugin XML file after the package has been successfully installed

This utility uses the plugin.py file as an entry point. This is suitable for running in Paraview in an environment that is not a virtual environment. It requires a Paraview installation of the plugin using pvpython. See the documentation for more details.

generate_plugin_in_virtualenv_after_install(output_file)

Utility for generating the plugin XML file after the package has been successfully installed

This utility uses the plugin.py file as an entry point. This is suitable for running in Paraview in an environment that is not a virtual environment. It requires a Paraview installation of the plugin using pvpython. See the documentation for more details.