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

Perfusion alignment doesn't output image #1235

Closed
chiharusako opened this issue Aug 7, 2020 · 22 comments
Closed

Perfusion alignment doesn't output image #1235

chiharusako opened this issue Aug 7, 2020 · 22 comments
Assignees

Comments

@chiharusako
Copy link
Contributor

Describe the bug
PerfusionAlignment only outputs csv and not an image.
Also, help documentation needs to be updated.

To Reproduce

$ dir="/cbica/home/sakoc/comp_space/lab/captk/180b/perfalign"
$ /cbica/software/lab/captk/centos7/1.8.0.Beta/bin/PerfusionAlignment \
       -i $dir/AAAA_2007.01.21_perf.nii.gz \
       -d $dir/AAAA_2007.01.21_anonymized_000.dcm \
       -o $dir/output \
       -b 15 -a 17 \
       -c $dir/AAAA_2007.01.21_t1ce.nii.gz \
       -e 0.045
base: 4.52968e-307 drop: 0 min: 1.52459e+07 max: 4.52968e-307
Finished successfully.

Press any key to continue............
$ ls $dir/output
original_curve.csv  revised_curve.csv

Expected behavior
Output an aligned perfusion image

CaPTk Version
1.8.0.Beta on cbica-cluster

Desktop (please complete the following information):

  • OS: centos7

Additional context
Documentation example says

Examples of Usage:
 Command: PerfusionAlignment -i AAAC_PreOp_perf_pp.nii.gz -d AAAC_PreOp_perf_pp.dcm -o <output dir>
 Result : Aligns the perfusion signal of the input image based on the time points

However there is no -d option in the required parameters.
Also, do we need the t1ce file and echo time? I gave it as parameters above as it won't run without it, but I am not sure if it is using it, especially if requiring the perfusion dicom as input.

@sarthakpati
Copy link
Contributor

Hi @chiharusako, this issue shoud be fixed buy #1291. Could you please verify this? The artifacts are here: https://dev.azure.com/CBICA/CaPTk/_build/results?buildId=2321&view=artifacts&type=publishedArtifacts

I am compiling this on my home directory, as well and it should be available on ~patis/testing/captkMyFork_1.8.0.nonRelease.20200908.834dc79

@chiharusako
Copy link
Contributor Author

@sarthakpati It still doesn't output an image. Also why do you need a t1ce input? Is it being used? If so, are there requirements for this, such as registered with perfusion etc?

dir=/cbica/home/sakoc/comp_space/lab/captk/180b/perfalign2

$ ~patis/testing/captkMyFork_1.8.0.nonRelease.20200908.834dc79/bin/PerfusionAlignment \
  -i $dir/ACST_2019.08.29_perf.nii.gz \
  -c $dir/ACST_2019.08.29_t1ce.nii.gz \
  -b 15 -a 17 -t 2 -o $dir/output > $dir/output/log

$ ls $dir/output
interpolated_curve.csv  original_curve.csv  revised_curve.csv  truncated_curve.csv

@sarthakpati
Copy link
Contributor

I think the T1Gd DICOM is required [ref] and not NIfTI.

@chiharusako
Copy link
Contributor Author

chiharusako commented Sep 9, 2020 via email

@sarthakpati
Copy link
Contributor

You are right; I was mistaken. The documentation needs to be updated after the usage has been finalized (I have no idea whether T1Gd is required or not).

@saimarathore
Copy link
Contributor

@chiharusako are you using the same input as you mentioned earlier? what time-resolution you are providing as input; this is different from echo time? time-resolution is generally 2sec for penn data having 45 time-points.

the code needs the following parameters as input:

  1. t1ce image
  2. perfusion image registered to t1ce
  3. time-points before drop
  4. time-points after drop
  5. output
  6. time-resolution

like this:
-i AAAC_PreOp_perf_pp.nii.gz -c AAAC_PreOp_t1ce_pp.nii.gz -b 15 -a 17 -t 2 -o

@chiharusako
Copy link
Contributor Author

@saimarathore Is the 6. time-resolution the time resolution (TR) for the input or output? Also why do you need a t1ce input?

@saimarathore
Copy link
Contributor

time-resolution is for the input perfusion image. it is actually the spacing in the 4th dimension, which is generally 2sec for perfusion images having 45 time-points.

@saimarathore
Copy link
Contributor

we need t1ce to write the aligned perfusion volumes in the t1ce space.

@chiharusako
Copy link
Contributor Author

I talked to @saimarathore
Here is my updated feedback and results, understanding the updated usage and required input.

Updated feedback:

  1. Instead of the t1ce input, the program should use the perfusion input to get image information for output. t1ce input requirement can be removed.
  2. As of now, it doesn't output a 4D aligned image. Instead, it outputs a series of 3D images. This should be combined to one 4D image as output.
  3. Also, the 3D image doesn't seem right when visualizing (screenshot below)
  4. The output 3D images are written to current folder, not specified output folder, which should be updated.
  5. Finally please update documentation on both website and CLI -h option so that the usage is clear. The part that wasn't clear was (a) you give input TR (b) output is always TR=1s and that is not a user input.

Updated Results: (the output nii.gz were written in current directory but I moved to the output folder)

$ dir=/cbica/home/sakoc/comp_space/lab/captk/180b/perfalign3
$ t=AAAA_2007.01.21
$ /cbica/home/patis/testing/captkMyFork_1.8.0.nonRelease.20200908.834dc79/bin/PerfusionAlignment \
     -i input/${t}_perf_LPS_rSRI_SSFinal.nii.gz \
     -c input/${t}_t1ce_LPS_rSRI_SSFinal.nii.gz \
     -b 15 -a 17 \
     -t 2 \
     -o out_$t > out_$t/log
$ mv out_*nii.gz out_$t
$ ls out_$t
interpolated_curve.csv	      out_AAAA_2007.01.2120.nii.gz  out_AAAA_2007.01.2127.nii.gz  out_AAAA_2007.01.2134.nii.gz	out_AAAA_2007.01.2141.nii.gz  out_AAAA_2007.01.2148.nii.gz
log			      out_AAAA_2007.01.2121.nii.gz  out_AAAA_2007.01.2128.nii.gz  out_AAAA_2007.01.2135.nii.gz	out_AAAA_2007.01.2142.nii.gz  revised_curve.csv
original_curve.csv	      out_AAAA_2007.01.2122.nii.gz  out_AAAA_2007.01.2129.nii.gz  out_AAAA_2007.01.2136.nii.gz	out_AAAA_2007.01.2143.nii.gz  truncated_curve.csv
out_AAAA_2007.01.2116.nii.gz  out_AAAA_2007.01.2123.nii.gz  out_AAAA_2007.01.2130.nii.gz  out_AAAA_2007.01.2137.nii.gz	out_AAAA_2007.01.2144.nii.gz
out_AAAA_2007.01.2117.nii.gz  out_AAAA_2007.01.2124.nii.gz  out_AAAA_2007.01.2131.nii.gz  out_AAAA_2007.01.2138.nii.gz	out_AAAA_2007.01.2145.nii.gz
out_AAAA_2007.01.2118.nii.gz  out_AAAA_2007.01.2125.nii.gz  out_AAAA_2007.01.2132.nii.gz  out_AAAA_2007.01.2139.nii.gz	out_AAAA_2007.01.2146.nii.gz
out_AAAA_2007.01.2119.nii.gz  out_AAAA_2007.01.2126.nii.gz  out_AAAA_2007.01.2133.nii.gz  out_AAAA_2007.01.2140.nii.gz	out_AAAA_2007.01.2147.nii.gz

image of one of the outputs. The intensity is bright on the outside and very low inside brain
image

@sarthakpati
Copy link
Contributor

From our meeting today, there are 2 things that need to be addressed:

  1. Instead of using T1Gd, use first time point of Perfusion image for computation
  2. Instead of writing N 3D volumes, write a single 4D volume

Is that right @saimarathore?

@sarthakpati sarthakpati self-assigned this Sep 16, 2020
@chiharusako
Copy link
Contributor Author

@sarthakpati Yes, and the 3 items I wrote before your comment..

sarthakpati added a commit to sarthakpati/CaPTk that referenced this issue Sep 16, 2020
@sarthakpati
Copy link
Contributor

sarthakpati commented Sep 16, 2020

Hey @chiharusako, I have made some changes. Could you please check on the cluster? It will be available in ~patis/testing/captkMyFork_1.8.0.nonRelease.20200916.596fd79

@chiharusako
Copy link
Contributor Author

chiharusako commented Sep 17, 2020

@sarthakpati It didn't finish. Did it work for you?

$ dir=/cbica/home/sakoc/comp_space/lab/captk/180b/perfalign4
$ /cbica/home/patis/testing/captkMyFork_1.8.0.nonRelease.20200916.596fd79/bin/PerfusionAlignment \
      -i input/AAAA_2007.01.21_perf_LPS.nii.gz \
      -b 15 -a 17 -t 2 \
      -o out_AAAA_2007.01.21 > out_AAAA_2007.01.21/log
$ tail out_AAAA_2007.01.21/log
82 : 275
83 : 275
84 : 276
85 : 276
86 : 275
87 : 275
88 : 275
89 : 0
Curve characteristics after base normalization::: base = 299; drop = 35; min = 194; max = 300
Segmentation fault

@sarthakpati
Copy link
Contributor

Yeah, I tried with a few images and it worked fine. Can you email/message the path to the image?

@chiharusako
Copy link
Contributor Author

/cbica/home/sakoc/comp_space/lab/captk/180b/perfalign4/input/AAAA_2007.01.21_perf_LPS.nii.gz
or
/cbica/home/sakoc/comp_space/lab/captk/180b/perfalign4/input/AAAA_2007.01.21_perf.nii.gz
if you need the 4th dimension to be correct (2s)

@sarthakpati
Copy link
Contributor

Got it. I can replicate the seg-fault. I will debug and let you know.

@sarthakpati
Copy link
Contributor

So, this is happening because the total number of volumes in the perfusion image is 45, drop is detected at 35 but the pointsAfterDrop parameter (-a in CLI) is 17, which makes the vector go out of range. I have added a message to tackle this:

Drop has been estimated at '35' and total number of time-points are '45' but time-points after drop is given as '10', which is not possible.

Let me know if you want some other wording.

@chiharusako
Copy link
Contributor Author

@sarthakpati The drop is not at 35 out of 45. Perhaps it's confusing the drop after resampling to 1 sec. For this example, the drop is around 17 out of 45 (curve below), 2sec interval. Once you resample to 1sec, it will have 90 timepoints and drop will be at around 35 but it should have enough timepoints after.

image

We can talk tomorrow if it helps.

@sarthakpati
Copy link
Contributor

sarthakpati commented Sep 17, 2020

Ah, now I understand this much better. Yes, it was trying to perform the extraction on the original perfusion, hence the error. I am testing a fix right now.

Update: e89823b seems to have fixed it. I am compiling on the cluster right now (and ready at ~patis/testing/captkMyFork_1.8.0.nonRelease.20200917.e89823b).

@sarthakpati
Copy link
Contributor

After conversing with Hamed, the function NormalizeBaselineValue needs to be re-written to ensure the baseline shift happens correctly.

@sarthakpati
Copy link
Contributor

Done.

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

3 participants