Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

patient_birth_date dtype should be signed integer in nibabel.ecat #1434

Open
@mcsitter

Description

@mcsitter

Hi,

I noticed that innibabel/ecat.py, thepatient_birth_date field is defined as:

('patient_birth_date',np.uint32),

This causes incorrect date interpretations, for example producing birth dates in the future rather than before the Unix epoch. It seems this field should be asigned integer (np.int32) to correctly handle dates.

At least in the ECAT files I have,patient_birth_datemust be signed integers to interpret dates correctly. Tools like Vinci read these files correctly when treated as signed.

Example:

importnumpyasnpimportdatetime,calendar# 19 Dec 1915 at midnight UTCts=calendar.timegm(datetime.datetime(1915,12,19).timetuple())# Structured array with wrong dtypedtype_wrong= [('patient_birth_date',np.uint32)]arr_wrong=np.array([(ts,)],dtype=dtype_wrong)# Structured array with correct dtypedtype_right= [('patient_birth_date',np.int32)]arr_right=np.array([(ts,)],dtype=dtype_right)# Convert back to datetimedt_wrong=datetime.datetime.utcfromtimestamp(arr_wrong['patient_birth_date'][0])dt_right=datetime.datetime.utcfromtimestamp(arr_right['patient_birth_date'][0])print("Unsigned (wrong):",arr_wrong['patient_birth_date'][0],"->",dt_wrong)print("Signed (correct):",arr_right['patient_birth_date'][0],"->",dt_right)

Example output:

Unsigned (wrong): 2589690496 -> 2052-01-24 06:28:16Signed (correct): -1705276800 -> 1915-12-19 00:00:00

Changing it tonp.int32 fixes this issue. I can also prepare aPR for this update if that’s helpful.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp