Closed arcolombo closed 2 months ago
i think the issue is with the EBI image 'computeFeatures.moment' which computes the m.cx and m.cy is an odd origin Using this code for any typical mask, i see that the m.cy has a different orientation compared to the original mask
obj2 = computeFeatures.moment(cust_masks[[id]]) xy2 = data.frame(X=obj2[,'m.cx'],Y=obj2[,'m.cy']) pp2 = st_as_sf(xy2,coords=c('X','Y'))
here is the attached mask and if you call computeFeatures.moment on it, the directions of the coordinates do not match the original mask
The origin of the coordinate system that EBImage
is using (top left corner) is in line with other conventions for coordinate systems (https://scikit-image.org/docs/stable/user_guide/numpy_images.html#coordinate-conventions). Just the coordinate system in R (origin in bottom left corner) does not fit to these conventions. So if you want to visualize the cells' coordinates matching to the image you would need to reverse the y axis (as is done in plotSpatial by default; see flip_y
). This has no effect on spatial calculations as they most often rely onn euclidean distances between points.
I'm a bit confused as the mask that you send does not match the images that you posted in your original message. Is that correct?
Hi thank you. yes that may have been a different sample as the mask, but the plotSpatial is what i will use. happy to close this. makes sense. thank you
Ok, great! Closing now.
Hi so if i generate a mask using CP the mask matches the original image as expected.
After i use cytomapper to create the objects issuing
cust_sce <- measureObjects(masks,restack, img_id = "ImageNb") the cust_sce has m.cx and m.cy columns appended to each object. however if i plot the m.cx and m.cy using any spatial software in R (spatstat etc) the y-axis directions are flipped compared to the original. i'm not sure if any has replicated this or if there is a different reference point starting in a different cartesian coordinate system? thank you