NMRPy / nmrpy

A Python module for processing NMR spectra.
BSD 3-Clause "New" or "Revised" License
20 stars 10 forks source link

phasing #8

Open ReinerD opened 9 months ago

ReinerD commented 9 months ago

Hello, I'm trying to use nmrpy to handle an array of solid state T1rho data. While the original data has been phased using topspin, I'm struggling to get the spectra phased using the module. Is there a way to set the phc0 and phc1 parameters (known from the topspin procs) directly?

jmrohwer commented 9 months ago

Hi Reiner,

Yes this is possible using the .ps_fids() method of FidArray. See here: https://nmrpy.readthedocs.io/en/latest/quickstart.html#phase-correction https://nmrpy.readthedocs.io/en/latest/data_objects.html#nmrpy.data_objects.FidArray.ps_fids

ReinerD commented 8 months ago

Hi Johann,

It works! :-) Thanks a lot for your help.

I do have another question now: I have two fid_arrays (from 2 pseudo 2D spectra) - how can I fuse them ?

I tried this, unsuccessfully:

fid_array1 = nmrpy.from_path(t1rho_data_folder1) fid_array2 = nmrpy.from_path(t1rho_data_folder2)

fid_array1.add_fids(fid_array2.get_fids())

On 12 Jan 2024, at 09:55, Johann Rohwer @.***> wrote:

Hi Reiner,

Yes this is possible using the .ps_fids() method of FidArray. See here: https://nmrpy.readthedocs.io/en/latest/quickstart.html#phase-correction https://nmrpy.readthedocs.io/en/latest/quickstart.html#phase-correction https://nmrpy.readthedocs.io/en/latest/data_objects.html#nmrpy.data_objects.FidArray.ps_fids https://nmrpy.readthedocs.io/en/latest/data_objects.html#nmrpy.data_objects.FidArray.ps_fids — Reply to this email directly, view it on GitHub https://github.com/NMRPy/nmrpy/issues/8#issuecomment-1888684940, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS4FAPQP25A34KSVOOAU5TYOD26TAVCNFSM6AAAAABBXYTEASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBYGY4DIOJUGA. You are receiving this because you authored the thread.

jmrohwer commented 8 months ago

This has to do with the way add_fids works, and with the uniqueness of the Fid IDs (fid.id). This ID starts at zero and is incremented automatically when the FidArray is instantiated. This means your FIDs inside fid_array1 and fid_array2 have the same IDs, both starting from zero (try it1!). So the call fid_array1.add_fids(fid_array2.get_fids()) will just replace the FIDs in array1 with those from array2 because it works on the IDs and the ID has to be unique.

The way to solve this is to first create a new list containing all the fids from both arrays, then create a new empty FidArray, and add the combined list to that array. When the new FidArray is populated, the IDs are recreated starting from zero.

combined = fid_array1.get_fids() + fid_array2.get_fids()
new_fa = nmrpy.data_objects.FidArray()
new_fa.add_fids(combined)
ReinerD commented 8 months ago

Works, till the next step:

new_fa.emhz_fids(lb=10) new_fa.ft_fids()

Fourier-transformation completed

but:

new_fa.plot_array()

fails with a TypeError since new_fa._params is None

I could get around that with

new_fa._params=fid_array1._params

but now it still fails with:

On 23 Jan 2024, at 14:26, Johann Rohwer @.***> wrote:

This has to do with the way add_fids works, and with the uniqueness of the Fid IDs (fid.id). This ID starts at zero and is incremented automatically when the FidArray is instantiated. This means your FIDs inside fid_array1 and fid_array2 have the same IDs, both starting from zero (try it1!). So the call fid_array1.add_fids(fid_array2.get_fids()) will just replace the FIDs in array1 with those from array2 because it works on the IDs and the ID has to be unique.

The way to solve this is to first create a new list containing all the fids from both arrays, then create a new empty FidArray, and add the combined list to that array. When the new FidArray is populated, the IDs are recreated starting from zero.

combined = fid_array1.get_fids() + fid_array2.get_fids() new_fa = nmrpy.data_objects.FidArray() new_fa.add_fids(combined) — Reply to this email directly, view it on GitHub https://github.com/NMRPy/nmrpy/issues/8#issuecomment-1906054487, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS4FAKLD7JCLD6QVVDNTXTYP626VAVCNFSM6AAAAABBXYTEASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWGA2TINBYG4. You are receiving this because you authored the thread.

ReinerD commented 8 months ago

Ok I got around that hurdle with

new_fa._params=fid_array1._params new_fa._params['acqtime']=np.concatenate((new_fa._params['acqtime'],fid_array2._params['acqtime']))

On 23 Jan 2024, at 14:26, Johann Rohwer @.***> wrote:

This has to do with the way add_fids works, and with the uniqueness of the Fid IDs (fid.id). This ID starts at zero and is incremented automatically when the FidArray is instantiated. This means your FIDs inside fid_array1 and fid_array2 have the same IDs, both starting from zero (try it1!). So the call fid_array1.add_fids(fid_array2.get_fids()) will just replace the FIDs in array1 with those from array2 because it works on the IDs and the ID has to be unique.

The way to solve this is to first create a new list containing all the fids from both arrays, then create a new empty FidArray, and add the combined list to that array. When the new FidArray is populated, the IDs are recreated starting from zero.

combined = fid_array1.get_fids() + fid_array2.get_fids() new_fa = nmrpy.data_objects.FidArray() new_fa.add_fids(combined) — Reply to this email directly, view it on GitHub https://github.com/NMRPy/nmrpy/issues/8#issuecomment-1906054487, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS4FAKLD7JCLD6QVVDNTXTYP626VAVCNFSM6AAAAABBXYTEASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWGA2TINBYG4. You are receiving this because you authored the thread.