Allen Cell Discussion Forum

Error Loading Images in Look Up Table

Hi all,

I’ve run into loading images in the look up table demo. Here’s the code:

Loading the data

FILE_NAME = ‘\Users\Desktop\AICSTest.tif’

reader = AICSImage(FILE_NAME)

IMG = reader.data.astype(np.float32)

print(IMG.shape)

File “”, line 1
FILE_NAME = ‘\Users\Desktop\AICSTest.tif’
^
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 0-1: truncated \UXXXXXXXX escape

I’ve also tried normalizing the string in a number of ways and I get a File Not Found error.

Loading the data

FILE_NAME = r’\Users\Desktop\AICSTest.tif’

reader = AICSImage(FILE_NAME)

IMG = reader.data.astype(np.float32)

print(IMG.shape)


FileNotFoundError Traceback (most recent call last)
in
1 FILE_NAME = r’\Users\Desktop\AICSTest.tif’
----> 2 reader = AICSImage(FILE_NAME)
3 IMG = reader.data.astype(np.float32)
4
5 print(IMG.shape)

Any one have any thoughts on this?

Thanks,
Aidan

can you remind me if you are using windows? or Mac?

Windows! Sorry for not clarifying.

Aidan

a couple of things to check:

(1) make sure your file realy exists
(2) your file path does not seem to be correct full path, should it be something like C://Users/…
(3) you can also try a relative path, namely, copying your tiff file to the same directory as where you start your jupyter. then, use filename only to load the image

Hi Jianxu,

Option number 3 worked! I’m not sure why loading from my desktop didn’t work as the file definitely exists but this works for me!

Best,
Aidan

In a normal string, try doubling the backslashes in your paths. For example, ’\Users\Desktop\AICSTest.tif’ becomes ‘\\Users\\Desktop\\AICSTest.tif’. Python interprets a single backslash as an “escape” character and is trying to interpret “\U” as a special thing. Your “r” string would have worked but I believe was missing the C: drive designator, as Jianxu mentioned. You should then be able to load files from your desktop.

Thanks all for the responses. I managed to upload an image by loading the file into the jupyter path.

When I exported I used r’\C:\Users\elcid\DeskTop\test_segmentation.tiff’ path which worked (a few other permutations did not).

Best,
Aidan