pyhrf.parcellation module¶
-
class
pyhrf.parcellation.
Ant
(a_id, greed, graph, labels, path_marks, site_marks, pressures, world, verbosity=0)¶ Bases:
pyhrf.parcellation.Talker
-
action
(time)¶
-
fix_explosion
()¶
-
to_conquer
()¶
-
to_patrol
()¶
-
-
class
pyhrf.parcellation.
Talker
(talker_string_id, verbosity=0)¶ -
verbose
(level, msg)¶
-
verbose_array
(level, array)¶
-
-
pyhrf.parcellation.
Visit_graph_noeud
(noeud, graphe, Visited=None)¶
-
class
pyhrf.parcellation.
World
(graph, nb_ants, greed=0.05, time_min=100, time_max=None, tolerance=1, verbosity=0, stop_when_all_controlled=False)¶ Bases:
pyhrf.parcellation.Talker
-
balanced
()¶
-
force_end
()¶
-
get_final_labels
()¶
-
resolve
()¶
-
site_taken
(site)¶
-
-
pyhrf.parcellation.
init_edge_data
(g, init_value=0)¶
-
pyhrf.parcellation.
make_parcellation_cubed_blobs_from_file
(parcellation_file, output_path, roi_ids=None, bg_parcel=0, skip_existing=False)¶
-
pyhrf.parcellation.
make_parcellation_from_files
(betaFiles, maskFile, outFile, nparcels, method, dry=False, spatial_weight=10.0)¶
-
pyhrf.parcellation.
make_parcellation_surf_from_files
(beta_files, mesh_file, parcellation_file, nbparcel, method, mu=10.0, verbose=0)¶
-
pyhrf.parcellation.
parcellate_balanced_vol
(mask, nb_parcels)¶ - Performs a balanced partitioning on the input mask using a balloon patroling
- algorithm [Eurol 2009]. Values with 0 are discarded position in the mask.
Parameters: - mask (-) – binary 3D array of valid position to parcellate
- nb_parcels (-) – the required number of parcels
Returns: - the parcellation – a 3D array of integers
Return type: numpy.ndarray
-
pyhrf.parcellation.
parcellate_voronoi_vol
(mask, nb_parcels, seeds=None)¶ Produce a parcellation from a Voronoi diagram built on random seeds. The number of seeds is equal to the nb of parcels. Seed are randomly placed within the mask, expect on edge positions
Parameters: - mask (-) – binary 3D array of valid position to parcellate
- nb_parcels (-) – the required number of parcels
- seeds (-) – TODO
Returns: - the parcellation – a 3D array of integers -
Return type: numpy.ndarray
-
pyhrf.parcellation.
parcellation_dist
(p1, p2, mask=None)¶ Compute the distance between the two parcellation p1 and p2 as the minimum number of positions to remove in order to obtain equal partitions. “mask” may be a binary mask to limit the distance computation to some specific positions. Important convention: parcel label 0 is treated as background and corresponding positions are discarded if no mask is provided.
Returns: (distance value, parcellation overlap)
-
pyhrf.parcellation.
parcellation_for_jde
(fmri_data, avg_parcel_size=250, output_dir=None, method='gkm', glm_drift='Cosine', glm_hfcut=128)¶ method: gkm, ward, ward_and_gkm
-
pyhrf.parcellation.
parcellation_report
(d)¶
-
pyhrf.parcellation.
parcellation_ward_spatial
(func_data, n_clusters, graph=None)¶ Make parcellation based upon ward hierarchical clustering from scikit-learn Inputs: - func_data: functional data: array of shape
(nb_positions, dim_feature_1, [dim_feature2, ...])- n_clusters: chosen number of clusters to create
- graph: adjacency list defining neighbours (if None, no connectivity defined: clustering is spatially
independent)
Output: parcellation labels
-
pyhrf.parcellation.
permutation
(x)¶ Randomly permute a sequence, or return a permuted range.
If x is a multi-dimensional array, it is only shuffled along its first index.
Parameters: x (int or array_like) – If x is an integer, randomly permute np.arange(x)
. If x is an array, make a copy and shuffle the elements randomly.Returns: out – Permuted sequence or array range. Return type: ndarray Examples
>>> np.random.permutation(10) array([1, 7, 4, 3, 0, 9, 2, 5, 8, 6])
>>> np.random.permutation([1, 4, 9, 12, 15]) array([15, 1, 9, 4, 12])
>>> arr = np.arange(9).reshape((3, 3)) >>> np.random.permutation(arr) array([[6, 7, 8], [0, 1, 2], [3, 4, 5]])
-
pyhrf.parcellation.
rand
(d0, d1, ..., dn)¶ Random values in a given shape.
Create an array of the given shape and populate it with random samples from a uniform distribution over
[0, 1)
.Parameters: d1, ..., dn (d0,) – The dimensions of the returned array, should all be positive. If no argument is given a single Python float is returned. Returns: out – Random values. Return type: ndarray, shape (d0, d1, ..., dn)
See also
random()
Notes
This is a convenience function. If you want an interface that takes a shape-tuple as the first argument, refer to np.random.random_sample .
Examples
>>> np.random.rand(3,2) array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #random
-
pyhrf.parcellation.
randint
(low, high=None, size=None, dtype='l')¶ Return random integers from low (inclusive) to high (exclusive).
Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low).
Parameters: - low (int) – Lowest (signed) integer to be drawn from the distribution (unless
high=None
, in which case this parameter is the highest such integer). - high (int, optional) – If provided, one above the largest (signed) integer to be drawn
from the distribution (see above for behavior if
high=None
). - size (int or tuple of ints, optional) – Output shape. If the given shape is, e.g.,
(m, n, k)
, thenm * n * k
samples are drawn. Default is None, in which case a single value is returned. - dtype (dtype, optional) –
Desired dtype of the result. All dtypes are determined by their name, i.e., ‘int64’, ‘int’, etc, so byteorder is not available and a specific precision may have different C types depending on the platform. The default value is ‘np.int’.
New in version 1.11.0.
Returns: out – size-shaped array of random integers from the appropriate distribution, or a single such random int if size not provided.
Return type: int or ndarray of ints
See also
random.random_integers()
- similar to randint, only for the closed interval [low, high], and 1 is the lowest value if high is omitted. In particular, this other one is the one to use to generate uniformly distributed discrete non-integers.
Examples
>>> np.random.randint(2, size=10) array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0]) >>> np.random.randint(1, size=10) array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
Generate a 2 x 4 array of ints between 0 and 4, inclusive:
>>> np.random.randint(5, size=(2, 4)) array([[4, 0, 2, 1], [3, 2, 2, 0]])
- low (int) – Lowest (signed) integer to be drawn from the distribution (unless
-
pyhrf.parcellation.
random_pick
(a)¶
-
pyhrf.parcellation.
round_nb_parcels
(n)¶
-
pyhrf.parcellation.
split_big_parcels
(parcel_file, output_file, max_size=400)¶
-
pyhrf.parcellation.
split_parcel
(labels, graphs, id_parcel, n_parcels, inplace=False, verbosity=0, balance_tolerance='exact')¶ balance_tolerance : exact or draft