Calculating Signal to Noise of Peaks

Hi,

I’ve attempted to run the following python script to estimate signal to noise

    for peak in current.peaks: 
        print(f`Pid: {peak.pid}, S/N: {peak.signalToNoiseRatio}`)

When I attempt to run it, I get the following error (screenshot below)

File "<ipython-input-1-cc6228805912>", line 2
    print(f`Pid: {peak.pid}, S/N: {peak.signalToNoiseRatio}`)
           ^
SyntaxError: invalid syntax

Error

Any help on what I might be doing wrong? Thank you!

Looks as if you are using ` rather than ’ in your format statement.

SoMB, MVLS, University of Glasgow

Hello,

I have now input the character ’ into the format statement. This is now the error I receive.

Error

Hi,

well your macro works for me when I replace the ` by '. But it could still be some issue with the quotes. You could try double quotes instead:

for peak in current.peaks: 
        print(f"Pid: {peak.pid}, S/N: {peak.signalToNoiseRatio}")

Note that if your quotes are being recognised correctly, the colouring of the code in the Analysis Console should look like that below. In your (original) screenshot the whole of the section inside the print ()s is black and not colour coded.

Vicky