862c3ed042ada33d2824e67e47bd92ef0881cf00,cellprofiler/modules/relateobjects.py,RelateObjects,calculate_minimum_distances,#RelateObjects#Any#Any#,451

Before Change



            // Finally, find the minimum distance per child
            min_dist = centrosome.cpmorphology.fixup_scipy_ndimage_result(
                scipy.ndimage.minimum(dist, clabel, numpy.arange(len(ccounts)))
            )

            // Account for unparented children
            dist = numpy.array([numpy.NaN] * len(mask))

After Change


            // Sort the points by label //
            reverse_column_order = range(children.dimensions)[::-1]

            coordinates = perim_loc[:, reverse_column_order].transpose().tolist()

            coordinates.append(perim_idx)

            idx = numpy.lexsort(coordinates)

            perim_loc = perim_loc[idx, :]

            perim_idx = perim_idx[idx]

            // Get counts and indexes to each run of perimeter points
            counts = scipy.ndimage.sum(
                numpy.ones(len(perim_idx)), perim_idx, numpy.arange(1, perim_idx[-1] + 1)
            ).astype(numpy.int32)

            indexes = numpy.cumsum(counts) - counts

            // For the children, get the index and count of the parent
            ccounts = counts[parents_of_masked]

            cindexes = indexes[parents_of_masked]

            // Now make an array that has an element for each of that child"s perimeter points
            clabel = numpy.zeros(numpy.sum(ccounts), int)

            // cfirst is the eventual first index of each child in the clabel array
            cfirst = numpy.cumsum(ccounts) - ccounts

            clabel[cfirst[1:]] += 1

            clabel = numpy.cumsum(clabel)

            // Make an index that runs from 0 to ccounts for each child label.
            cp_index = numpy.arange(len(clabel)) - cfirst[clabel]

            // then add cindexes to get an index to the perimeter point
            cp_index += cindexes[clabel]

            // Now, calculate the distance from the centroid of each label to each perimeter point in the parent.
            dist = numpy.sqrt(numpy.sum((perim_loc[cp_index, :] - ccenters[clabel, :]) ** 2, 1))

            // Finally, find the minimum distance per child
            min_dist = scipy.ndimage.minimum(dist, clabel, numpy.arange(len(ccounts)))

            // Account for unparented children
            dist = numpy.array([numpy.NaN] * len(mask))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: CellProfiler/CellProfiler
Commit Name: 862c3ed042ada33d2824e67e47bd92ef0881cf00
Time: 2017-04-19
Author: mcquin@users.noreply.github.com
File Name: cellprofiler/modules/relateobjects.py
Class Name: RelateObjects
Method Name: calculate_minimum_distances


Project Name: mne-tools/mne-python
Commit Name: 2dd49058dba6cf1527e2414221d4b08b127f96d5
Time: 2019-04-24
Author: larson.eric.d@gmail.com
File Name: mne/forward/forward.py
Class Name:
Method Name: compute_depth_prior


Project Name: Calamari-OCR/calamari
Commit Name: 8d0d0c7a6db3904f0222cbe058388a92cf21a548
Time: 2021-02-06
Author: ChWick@users.noreply.github.com
File Name: calamari_ocr/thirdparty/ocrodeg/degrade.py
Class Name:
Method Name: random_blotches