Get histogram of vector volume

I tried to get the histogram of the R, A, and S axes of the DVF of the contour thing by modifying the code that you taught me before.

However, I wrote the following code, but an error occurred.
I would like to know if there is any improvement.

labelValue = 1
Loading with imageIOName: GDCM

labelmapVolumeNode =slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLLabelMapVolumeNode”)
volumeNode = getNode(‘Displacement Field’)
labelmapVolumeNode = getNode(‘LabelMapVolume’)
segmentationNode = getNode(‘segmentation’)
segmentId = ‘box’
slicer.modules.segmentations.logic().ExportVisibleSegmentsToLabelmapNode(segmentationNode, labelmapVolumeNode, volumeNode)
True
volumeArray = slicer.util.arrayFromVolume(volumeNode)
labelArray = slicer.util.arrayFromVolume(labelmapVolumeNode)
import numpy as np
histogram = np.histogram(arrayFromVolume(volumeNode), bins=100)
histogramInSegment = histogram[arrayFromSegmentBinaryLabelmap(segmentationNode, segmentId) != 0]
Traceback (most recent call last):
File “”, line 1, in
TypeError: only integer scalar arrays can be converted to a scalar index

In addition, I have two questions.
(1) What is the unit of the X-axis of DVF?
Is it in mm or cm?
(2) I would also like to know which axes A, S, and R in 3DSlicer represent respectively.

There is a fundamental issue with this line. It seems that you want to filter parts of the histogram using spatial positions, which is impossible, because the histogram bins contain voxel count for the entire input array. You need to select the voxels that you are interested in before computing the histogram.

In DICOM and by default in Slicer, all length units are millimeter.

Patient coordinate system directions, as defined in the DICOM standard (A = anterior = -posterior; S = superior; R = right = -left).