Metadata Regular Expression Question

Hi,

I am trying to set up a new regular expression to extract from my file names. The files names are in the form:

(1)_DAPI_20_F_image 000084
(1)_mCherry_600_F_image 000083
(1)_Venus_1000_F_image 000082

I am trying to extract the first number within the brackets, the channel and then the number at the end.

I have the string below which I put together using https://regex101.com/r/IVhjys/1/. It looks to be fine on there but when I move to CP I get the error “incomplete or badly formatted repeat expression”

^((?P)[0-9])((?P)[A-Z]{4,}).* .tif

Would anyone be able to help with this as I know it should be quite simple but none of my attempts so far have worked!

Thanks!

Hi CA1,
This should put you on good tracks :wink:
^[(](?P<FirstNumber>[0-9]*)[)]_(?P<Channel>.*)_[0-9]*_F_image (?P<NumberAtTheEnd>[0-9].*)
The issue was probably coming from the brackets…
Good luck
Fabien

Hi Fabien,

Thank you so much for your super quick help! For some reason when I pasted my previous attempt in the message it showed the full regular expression when drafting/editing my message but then doesn’t show anything between <> in my regular expression in my posted message.

Thank you so much for the advice, I have edited as you suggest. This now looks to select the correct parts of the identification when using the checker in CP but is not extracting correctly when I do the update check on the images as shown below.

It instead identifies the Field as the Channel and the Channel as the ImageNumber and doesn’t seem to have a column for the ImageNumber at the end. Do you have any thoughts on this?

image

Apologies to ask for more advice!

Sometimes there’s some bugs… plus in your case the brackets definitely are not helping :wink:
Nevertheless in can help to split the regex in different extraction methods.
And in your case it’s working (at least on my computer) when including the brackets in the metadata:
image
image
Cheers,
Fabien

Hi Fabien,

Many thanks for your reply - perhaps I need to reinstall CP and see if that sorts it!

I know - not an ideal naming convention! Unfortunately they are a colleagues’ images I offered to try and help improve the analysis with - going forward I will suggest a slightly different format as I’ve not had such issues with the regular expression before!

Thank you :smiley:

In case it helps anyone else, it’s now working when I split over two different extractions whereas it didn’t work when combined into one.Thank you ever so much, Fabien.

image