nipype.interfaces.cmtk.nx module

AverageNetworks

Link to code

Bases: BaseInterface

Calculates and outputs the average network given a set of input NetworkX gpickle files

This interface will only keep an edge in the averaged network if that edge is present in at least half of the input networks.

Example

>>> import nipype.interfaces.cmtk as cmtk
>>> avg = cmtk.AverageNetworks()
>>> avg.inputs.in_files = ['subj1.pck', 'subj2.pck']
>>> avg.run()                 
Mandatory Inputs:

in_files (a list of items which are a pathlike object or string representing an existing file) – Networks for a group of subjects.

Optional Inputs:
  • group_id (a string) – ID for group. (Nipype default value: group1)

  • out_gexf_groupavg (a pathlike object or string representing a file) – Average network saved as a .gexf file.

  • out_gpickled_groupavg (a pathlike object or string representing a file) – Average network saved as a NetworkX .pck.

  • resolution_network_file (a pathlike object or string representing an existing file) – Parcellation files from Connectome Mapping Toolkit. This is not necessary, but if included, the interface will output the statistical maps as networkx graphs.

Outputs:
  • gexf_groupavg (a pathlike object or string representing a file) – Average network saved as a .gexf file.

  • gpickled_groupavg (a pathlike object or string representing a file) – Average network saved as a NetworkX .pck.

  • matlab_groupavgs (a list of items which are a pathlike object or string representing a file)

NetworkXMetrics

Link to code

Bases: BaseInterface

Calculates and outputs NetworkX-based measures for an input network

Example

>>> import nipype.interfaces.cmtk as cmtk
>>> nxmetrics = cmtk.NetworkXMetrics()
>>> nxmetrics.inputs.in_file = 'subj1.pck'
>>> nxmetrics.run()                 
Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Input network.

Optional Inputs:
  • compute_clique_related_measures (a boolean) – Computing clique-related measures (e.g. node clique number) can be very time consuming. (Nipype default value: False)

  • out_edge_metrics_matlab (a pathlike object or string representing a file) – Output edge metrics in MATLAB .mat format.

  • out_global_metrics_matlab (a pathlike object or string representing a file) – Output node metrics in MATLAB .mat format.

  • out_k_core (a pathlike object or string representing a file) – Computed k-core network stored as a NetworkX pickle. (Nipype default value: k_core)

  • out_k_crust (a pathlike object or string representing a file) – Computed k-crust network stored as a NetworkX pickle. (Nipype default value: k_crust)

  • out_k_shell (a pathlike object or string representing a file) – Computed k-shell network stored as a NetworkX pickle. (Nipype default value: k_shell)

  • out_node_metrics_matlab (a pathlike object or string representing a file) – Output node metrics in MATLAB .mat format.

  • out_pickled_extra_measures (a pathlike object or string representing a file) – Network measures for group 1 that return dictionaries stored as a Pickle. (Nipype default value: extra_measures)

  • treat_as_weighted_graph (a boolean) – Some network metrics can be calculated while considering only a binarized version of the graph. (Nipype default value: True)

Outputs:
  • edge_measure_networks (a list of items which are a pathlike object or string representing a file)

  • edge_measures_matlab (a pathlike object or string representing a file) – Output edge metrics in MATLAB .mat format.

  • global_measures_matlab (a pathlike object or string representing a file) – Output global metrics in MATLAB .mat format.

  • gpickled_network_files (a list of items which are a pathlike object or string representing a file)

  • k_core (a pathlike object or string representing a file) – Computed k-core network stored as a NetworkX pickle.

  • k_crust (a pathlike object or string representing a file) – Computed k-crust network stored as a NetworkX pickle.

  • k_networks (a list of items which are a pathlike object or string representing a file)

  • k_shell (a pathlike object or string representing a file) – Computed k-shell network stored as a NetworkX pickle.

  • matlab_dict_measures (a list of items which are a pathlike object or string representing a file)

  • matlab_matrix_files (a list of items which are a pathlike object or string representing a file)

  • node_measure_networks (a list of items which are a pathlike object or string representing a file)

  • node_measures_matlab (a pathlike object or string representing a file) – Output node metrics in MATLAB .mat format.

  • pickled_extra_measures (a pathlike object or string representing a file) – Network measures for the group that return dictionaries, stored as a Pickle.

nipype.interfaces.cmtk.nx.add_dicts_by_key(in_dict1, in_dict2)

Combines two dictionaries and adds the values for those keys that are shared

nipype.interfaces.cmtk.nx.add_edge_data(edge_array, ntwk, above=0, below=0)
nipype.interfaces.cmtk.nx.add_node_data(node_array, ntwk)
nipype.interfaces.cmtk.nx.average_networks(in_files, ntwk_res_file, group_id)

Sums the edges of input networks and divides by the number of networks Writes the average network as .pck and .gexf and returns the name of the written networks

nipype.interfaces.cmtk.nx.compute_dict_measures(ntwk)

Returns a dictionary

nipype.interfaces.cmtk.nx.compute_edge_measures(ntwk)

These return edge-based measures

nipype.interfaces.cmtk.nx.compute_network_measures(ntwk)
nipype.interfaces.cmtk.nx.compute_node_measures(ntwk, calculate_cliques=False)

These return node-based measures

nipype.interfaces.cmtk.nx.compute_singlevalued_measures(ntwk, weighted=True, calculate_cliques=False)

Returns a single value per network

nipype.interfaces.cmtk.nx.fix_keys_for_gexf(orig)

GEXF Networks can be read in Gephi, however, the keys for the node and edge IDs must be converted to strings

nipype.interfaces.cmtk.nx.read_unknown_ntwk(ntwk)
nipype.interfaces.cmtk.nx.remove_all_edges(ntwk)