A method of detecting positional displacement of a sample container, the method detecting an amount of positional displacement of a sample container having a plurality of sample storage portions from an ideal placement state for when the sample container is placed in a sample container holding portion of an imaging device, and the method comprising: a sample storage portion selecting step of selecting two sample storage portions from among the plurality of sample storage portions, as positional displacement detection sample storage portions; a logical edge coordinates calculating step of calculating logical edge coordinates for each positional displacement detection sample storage portion based on information in a definition file on a configuration of the plurality of sample storage portions included in the sample container, the logical edge coordinates being coordinates of an upper edge, a lower edge, a left edge, and a right edge in the ideal placement state; an image capturing step of performing image capturing of a predetermined range with each set of logical edge coordinates being a center position, the each set of logical edge coordinates being calculated in the logical edge coordinates calculating step; a temporary edge coordinates detecting step of applying, for each positional displacement detection sample storage portion, a separability filter to each of captured images of an upper edge side, a lower edge side, a left edge side, and a right edge side obtained by the image capturing in the image capturing step, while shifting a center position of the separability filter, and detecting, for each captured image, coordinates of the center position of the separability filter obtained when a peak value of a separability is obtained, as temporary edge coordinates, the separability filter finding a separability between two regions; a center coordinates calculating step of calculating actual center coordinates for each positional displacement detection sample storage portion, based on the temporary edge coordinates for the upper edge side, the lower edge side, the left edge side, and the right edge side detected in the temporary edge coordinates detecting step; and an amount-of-positional-displacement calculating step of calculating an amount of positional displacement of the sample container from the ideal placement state, based on the center coordinates of each positional displacement detection sample storage portion calculated in the center coordinates calculating step. a sample storage portion selecting step of selecting two sample storage portions from among the plurality of sample storage portions, as positional displacement detection sample storage portions; a logical edge coordinates calculating step of calculating logical edge coordinates for each positional displacement detection sample storage portion based on information in a definition file on a configuration of the plurality of sample storage portions included in the sample container, the logical edge coordinates being coordinates of an upper edge, a lower edge, a left edge, and a right edge in the ideal placement state; an image capturing step of performing image capturing of a predetermined range with each set of logical edge coordinates being a center position, the each set of logical edge coordinates being calculated in the logical edge coordinates calculating step; a temporary edge coordinates detecting step of applying, for each positional displacement detection sample storage portion, a separability filter to each of captured images of an upper edge side, a lower edge side, a left edge side, and a right edge side obtained by the image capturing in the image capturing step, while shifting a center position of the separability filter, and detecting, for each captured image, coordinates of the center position of the separability filter obtained when a peak value of a separability is obtained, as temporary edge coordinates, the separability filter finding a separability between two regions; a center coordinates calculating step of calculating actual center coordinates for each positional displacement detection sample storage portion, based on the temporary edge coordinates for the upper edge side, the lower edge side, the left edge side, and the right edge side detected in the temporary edge coordinates detecting step; and an amount-of-positional-displacement calculating step of calculating an amount of positional displacement of the sample container from the ideal placement state, based on the center coordinates of each positional displacement detection sample storage portion calculated in the center coordinates calculating step.