Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Ill conditioned matrix" while trying to run kineticmodel SRTM #135

Open
cepa995 opened this issue Oct 22, 2024 · 6 comments
Open

"Ill conditioned matrix" while trying to run kineticmodel SRTM #135

cepa995 opened this issue Oct 22, 2024 · 6 comments

Comments

@cepa995
Copy link

cepa995 commented Oct 22, 2024

Hi,

I have successfully managed to clone and install your package, and I tried out SRTM method on my own data where as a reference mask I've used whole brain mask (for testing purposes).

Problem I am running into is that during the computation of DVR, while trying to fit Linear Regression model, it always seems to hit the LinAlgException where the b cannot be solved due to Ill-conditioned matrix, specifically at lines 254:

image

as well as line 311:

image

Although this may be "just a warning", could you help me understand the root of this issue and how can I address it? Why, and what matrix exactly is ill-conditioned?

Thanks!

@bilgelm
Copy link
Owner

bilgelm commented Nov 1, 2024

Hi @cepa995, thanks for your question!

Both of these computations are performed per voxel. I'm imaging that the warnings you're seeing are being generated at a small number of voxels relative to the number of voxels in the brain mask – perhaps some background voxels that got included in the mask you're using, or a voxel in or near the ventricles, or some other voxel where there isn't a clear time activity curve. The ill-conditioned matrix warning could also be stemming from voxels (especially voxels in the reference region) where the time activity curve (TAC) is very close to the mean TAC in the reference region. This would mean that the 2nd and 3rd columns of the matrix x are almost collinear, making it difficult to solve the linear system.

@cepa995
Copy link
Author

cepa995 commented Dec 19, 2024

Thanks @bilgelm, that makes sense!

@cepa995 cepa995 closed this as completed Dec 19, 2024
@cepa995
Copy link
Author

cepa995 commented Dec 19, 2024

Sorry, but I have a question. What is the target region in SRTM model? How do I define it? For exmaple, I want to use Whole Cerebellum as reference, and Hippocampus as target @bilgelm

@cepa995 cepa995 reopened this Dec 19, 2024
@bilgelm
Copy link
Owner

bilgelm commented Dec 19, 2024

Hi @cepa995,

An SRTM is fitted per voxel (if a 4-D PET image is supplied as input to kineticmodel) or per ROI (if a TAC tsv file is supplied). That is, each voxel/ROI is considered as target in separate SRTMs. After model fitting, you'll need to extract the results for the hippocampus (by using a hippocampus mask if you used a 4-D PET image as input to kineticmodel, or by getting the corresponding hippocampus entry from the output tsv file if you used a TAC tsv as input).

If you want to estimate SRTM kinetic parameters only in the hippocampus, you can speed up the computation by ignoring non-hippocampus:

  • if you're using a 4-D PET image as input, supply a binary mask of the hippocampus as the petmask argument to kineticmodel. This will result in kinetic parameter estimation to be skipped for voxels that are not in petmask.
  • if you're using a TAC tsv file as input, include only the TACs for your reference region (whole cerebellum) and the hippocampus as columns in the input TAC tsv file.

@cepa995
Copy link
Author

cepa995 commented Dec 19, 2024

I think I get it. So in summary, I can use typical reference region, such as Cerebellum or White Matter, and 4D PET image, estimate DVR, and then mask out hippocampus?

Regarding the 2nd option, I already tried that but I get an error that reference mask (e.g. white matter) does not fit into pet mask (hippocampus). So I guess I would need to supply entire brain mask, and later extraxt results per specific regions, like FDG stats, etc. Correct?

@bilgelm
Copy link
Owner

bilgelm commented Dec 19, 2024

Yes, that's right.

My bad re: the 2nd option -- the way it is currently implemented, you need to include the reference region in the petmask in addition to the hippocampus. From a user perspective, it makes more sense to use petmask to designate target voxels only. Leave this issue open and I'll make that update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants