You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm interested in using BaSiCPy on cell painting data (2D static images, one channel at a time), but I'm running into some trouble, which is that I can't get the fit() method to converge.
I'm using a numpy array as input, but that was just an educated guess based on some of the notebooks -- it looks like you're in the process of making some changes to the code / documentation?
I just get a non-convergence warning, and all nans for the darkfield and all zeros for the flatfield. I tired instantiating the basic object with some different parameters, but nothing seemed to help. Any suggestions?
# importsfrompathlibimportPathimportbasicpyimportnumpyasnpimportpandasaspdimportskimagefromaicsimageioimportAICSImage# load data / metadataDATA_PAR_DIR=Path(
"/nfs_home/projects/departments/cdd/data/rzdm/jumpcp_U2OS/output_data/AIUN_smORF_U2OS_exp1/Plate_11/"
)
df_images=pd.read_csv(DATA_PAR_DIR/"field_image_manifest.csv")[
["ImageStackName", "AICSImageRawPath"]
].drop_duplicates()
df_meta=pd.read_csv(DATA_PAR_DIR/"metadata.csv")
df_meta.Name=df_meta.Name.str.replace(r"d[0-9].TIFF$", "", regex=True)
df_meta=df_meta.rename(columns={"Name": "ImageStackName"})
df=df_meta.merge(df_images)
# work with just one wellwells=df.WellId.sample(1)
df_small=df[df.WellId.isin(wells)].reset_index(drop=True).copy()
# load imagesimages=dict(df_small[["ImageStackName", "AICSImageRawPath"]].values)
images= {k:AICSImage(v).get_image_data("YX", C=0) fork,vinimages.items()}
images= {k:skimage.img_as_float(v) fork,vinimages.items()}
images=np.stack(list(images.values())).astype(np.float32)
# illumination correctionbasic=basicpy.BaSiC(get_darkfield=True)
basic.fit(images)
P.S. I tried to see if the code would run correctly on the WSI data set, but the hash of the download has changed and threw an error when I tried to download it.
The text was updated successfully, but these errors were encountered:
After some digging into the tests on the dev branch, I believe the issue I was having is cause by the input array dtype. Am I correct in assuming that the fit method wants a uint16 array? The NaN / nonconvergent behaviour vanishes when I hit the array with skimage's img_as_uint before passing it to fit(). If so, that might be a useful thing to have as an error message, either refusing to proceed without an input of the right dtype, or converting it for the user (with an accompanying message).
I encountered the same problem even though my input image tensor is of dtype=uint16. Any other solution for the "WARNING:basicpy.basicpy:Reweighting did not converge." warning?
I encountered the same issue, and my flatfield image gave all Nan's.
However, this happens when I run the analysis on a certain subset of my data. If I run BaSic on another subset of the same dataset, even containing some of the same tiles, it doesn't give this convergence error.
It also gives this error when only looking at one tile. Is there a minimum amount of tiles required?
Hi, I'm interested in using BaSiCPy on cell painting data (2D static images, one channel at a time), but I'm running into some trouble, which is that I can't get the
fit()
method to converge.I'm using a numpy array as input, but that was just an educated guess based on some of the notebooks -- it looks like you're in the process of making some changes to the code / documentation?
Anyway, here's what I tried:
Load data:
At this point there are 8 images, all in an array of shape
images.shape = (8, 1104, 1104)
, withnp.all(np.isfinite(images))
returningTrue
.When I try to run the illumination correction:
I just get a non-convergence warning, and all nans for the darkfield and all zeros for the flatfield. I tired instantiating the
basic
object with some different parameters, but nothing seemed to help. Any suggestions?Full error message
Full python code
P.S. I tried to see if the code would run correctly on the WSI data set, but the hash of the download has changed and threw an error when I tried to download it.
The text was updated successfully, but these errors were encountered: