Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ jobs:
- name: Checkout xnat-docker-compose
uses: actions/checkout@v3
with:
repository: NrgXnat/xnat-docker-compose
ref: 1.8.1
repository: jhuguetn/xnat-docker-compose
ref: 1.8.10.5
path: xnat-docker-compose
- run: docker compose version
- run: python --version
- run: python -m pip install --upgrade pip
- name: Install dependencies
run: pip install -r requirements-dev.txt
- name: Start xnat-docker-compose
run: docker compose up -d
run: docker compose --env-file default.env up -d
working-directory: xnat-docker-compose
- run: sleep 120
if: ${{ matrix.python-version == '3.8' }}
Expand Down
23 changes: 23 additions & 0 deletions pyxnat/core/derivatives/centaurz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
XNAT_RESOURCE_NAMES = ['CENTAURZ']


def quantification_results(self):
import pandas as pd
from io import StringIO

f = self.file('centaurz_quantification_results.csv')
uri = f._uri
res = self._intf.get(uri).text
text = StringIO(res)
df = pd.read_csv(text)
return df


def centaurz(self, optimization='harmonized'):
"""Return the CenTauRz metric for the "Universal" region and given
optimization type. The default optimization ("harmonized") ensures
generalizability and robustness across tracers, scanners and projects."""
df = self.quantification_results()
q = 'region == "Universal" and measurement == "centaurz"'
q += f' and smoothing_type == "{optimization}"'
return float(df.query(q)['value'].iloc[0])
2 changes: 1 addition & 1 deletion pyxnat/core/derivatives/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def scandate(self):
fd, fp = tempfile.mkstemp(suffix='.dcm')
os.close(fd)
f.get(dest=fp)
d = pydicom.read_file(fp)
d = pydicom.dcmread(fp)

if hasattr(d, 'AcquisitionDate'):
acquisition_date = d.AcquisitionDate
Expand Down
6 changes: 1 addition & 5 deletions pyxnat/core/derivatives/pet_fdg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

def quantification_results(self):
import pandas as pd
import sys
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO
from io import StringIO

f = self.file('quantification_results.csv')
uri = f._uri
Expand Down
13 changes: 13 additions & 0 deletions pyxnat/tests/test_resource_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,16 @@ def test_bamos_arterial_stats():
r = e1.resource('BAMOS_ARTERIAL')
v = r.stats()
assert isclose(sum(v['volume']), 32995.6548)


def test_centaurz_quantification():
r = e1.resource('CENTAURZ')
c1 = r.centaurz()
c2 = r.centaurz(optimization='original')
q = 'region == "MesialTemporal" and smoothing_type == "{s_type}"'
rq1 = r.quantification_results().query(q.format(s_type="original"))
rq2 = r.quantification_results().query(q.format(s_type="harmonized"))
assert c1 > c2
assert not rq1.empty and not rq2.empty
assert rq1[rq1['measurement'] == 'suvr'].value.iloc[0] > 0.8
assert rq2[rq2['measurement'] == 'suvr_spm8'].value.iloc[0] < 0.8