Skip to content

code changes to handle single-file dicom and a new TR/TE header field - #180

Merged
tiborauer merged 9 commits into
automaticanalysis:masterfrom
jones-michael-s:philips_dicom_tweak
Jan 22, 2019
Merged

code changes to handle single-file dicom and a new TR/TE header field#180
tiborauer merged 9 commits into
automaticanalysis:masterfrom
jones-michael-s:philips_dicom_tweak

Conversation

@jones-michael-s

Copy link
Copy Markdown
Collaborator

See #178

There are 2 changed files in this PR:

aamod_convert_epis.m
aas_convertseries_fromstream.m

This includes Tibor's fix mentioned in the Issue, but also more code changes to address the followup problem I reported. The changes aren't extensive -- the new lines may even be indented uniquely to make them stand out. (I wish I could say I did that on purpose, but it's really that with the Matlab editor, vi, and github all treating indentation differently, I find it's impossible to format code consistently.)

I can't be sure this is a solid fix --- I only have two kinds of dicom I can test. All I can say is it fixed the problem I reported and didn't break anything new.

@tiborauer tiborauer self-assigned this Jan 9, 2019
@tiborauer

Copy link
Copy Markdown
Member

Is there a reason why you set the original field EchoTime (aas_convertseries_fromstream, lines 153 and 176)?

@tiborauer

Copy link
Copy Markdown
Member

Why do you multiply TR with 1000 (aas_convertseries_fromstream, lines 144)?

@jones-michael-s

jones-michael-s commented Jan 10, 2019

Copy link
Copy Markdown
Collaborator Author

Is there a reason why you set the original field EchoTime (aas_convertseries_fromstream, lines 153 and 176)?

infoD gets appended to DICOMHEADERS (line 245). Even if aa only ever uses TE, it seemed like good practice to make the two values consistent.

Why do you multiply TR with 1000 (aas_convertseries_fromstream, lines 144)?

I must have had some reason to think TR was expressed in seconds in this field so I converted to milliseconds. However, I've looked at a few more of these new Philiips dicoms today and all of them had TR in the field expressed in milliseconds. Is it possible for the value to be either seconds or milliseconds depending on a scanner setting? I can't find anything in the Philips documentation to confirm this (but TBH, the Philips documentation isn't very clear).

We must also consider the real explanation is: I screwed up. :-(

@tiborauer

Copy link
Copy Markdown
Member

infoD gets appended to DICOMHEADERS (line 245). Even if aa only ever uses TE, it seemed like good practice to make the two values consistent.

The idea is to keep the original 'raw' information untouched. That is why fields volumeTR and volumeTE have been created. Some modules/functions uses these raw field as 'backup'-s, and I do no think we should change them. If you do not mind, I would omit them.

I must have had some reason to think TR was expressed in seconds in this field so I converted to milliseconds. However, I've looked at a few more of these new Philiips dicoms today and all of them had TR in the field expressed in milliseconds. Is it possible for the value to be either seconds or milliseconds depending on a scanner setting? I can't find anything in the Philips documentation to confirm this (but TBH, the Philips documentation isn't very clear).

AFAIK, all values are usually in ms; even across vendors. However, our 'derived' fields (volumeTR, volumeTE, slicetime, echospacing) are in seconds, because that is what SPM (and BIDS) use. Again, I would omit them.

Both of these issues causes problem if you use fieldmaps and/or slicetiming relying on DICOM header.

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

Ok, I will edit the code and update the PR.

Thanks!

@tiborauer

Copy link
Copy Markdown
Member

I have done already. Still testing. Then I submit a PR to your branch. If you merge it, then your PR will be automatically updated.

@tiborauer

Copy link
Copy Markdown
Member

I am afraid I have accidentally pushed into your branch rather than creating a PR. I am so sorry. I hope you can agree in my changes...

If yes, then I am happy to merge your (already updated) PR.

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

I am afraid I have accidentally pushed into your branch rather than creating a PR. I am so sorry. I hope you can agree in my changes...

No problem -- your changes look good.

Did everything look ok in aamod_convert_epis.m (the other file in this PR)?

@tiborauer

tiborauer commented Jan 14, 2019

Copy link
Copy Markdown
Member

Thanks for highlighting it!

There was no issue at all, however, I would revert lines 423-425. Was there any reason why you removed reference to 'sess'? It allows to provide session-specific setting 'ignoreafter'.

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

Was there any reason why you removed reference to 'sess'? It allows to provide session-specific setting 'ignoreafter'.

Is '"ignoreafter" really session-specific? The default value listed in the xml header is a scalar. As such, passing sess > 1 to aas_getsetting causes aa to print the following (in big red letters):

WARNING: Setting has fewer then 2 elements.
WARNING: First value will be applied!

The first time I encountered this message, I spent a week trying to figure out what was wrong with my analysis. It turns out nothing was wrong with my analysis. The warning is simply unhelpful. So I turned it off by removing sess from the call to aas_getsetting.

If ignoreafter can be specified as a vector then, sure, sess should be passed to aas_getsetting. But can we at least reword the warning message to be more helpful? Something like:

Warning: A single value of the setting was found and will be used for this index (2).

@tiborauer

Copy link
Copy Markdown
Member

Yes, 'ignoreafter' can be a vector with session-specific values, so please, revert the changes!

I am sorry for the uninformative warning message. I am the one to be blamed. I agree that a more informative one would be preferable. Please, go ahead implementing it!

@jones-michael-s

jones-michael-s commented Jan 16, 2019

Copy link
Copy Markdown
Collaborator Author

Update:

  1. I added sess back to the call in aas_getsetting in aamod_convert_epi.m as requested
  2. I modified the error message in aas_getsetting (using feedback from our aa users here to try to make the message as helpful as possible).
  3. I added a comment in aamod_convert_epis.xml that ignoreafter can be defined as a vector, and that leaving it as a scalar will generate an error message.

I pushed these changes to my fork -- I think they will automatically show up here in the PR.

Thanks for all your help!
M

@tiborauer

Copy link
Copy Markdown
Member

Looks great! I am going to test again.

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

Hi Tibor,

I saw your modification of aas_getsetting in my fork. Apparently, pulling the caller off the stack using dbstack is bad?

Anyway, I merged your change just now.

Thanks again.

@tiborauer

Copy link
Copy Markdown
Member

Thanks!
dbstack failed for me. I think it works only when you are actually debugging a script but not in run-time. For that there is the exception stack I implemented.

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

Is there a reason why you set the original field EchoTime (aas_convertseries_fromstream, lines 153 and 176)?

I'm afraid we need to revisit this issue.

I've just discovered that if you don't set the original field EchoTime (as I had done), then aamod_convert_epis crashes immediately on these Philiips DICOMS.

Your reluctance to alter the original data because it provides a "backup" for other modules may well be true, but not setting the field makes it impossible for us to use this data.

Please advise.

@tiborauer

Copy link
Copy Markdown
Member

Can you send me the data?

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

What's the best way to send you the data?

@tiborauer

Copy link
Copy Markdown
Member

Whichever works for you(r institutional policy): tarred and zipped in Dropbox, GDrive, etc.

@tiborauer

tiborauer commented Jan 17, 2019

Copy link
Copy Markdown
Member

I have identified the issue: Your DICOM has no EchoTime at all!
In that special case, it does make sense to set it. Go ahead and then I (also) test it.

@tiborauer

Copy link
Copy Markdown
Member

I suggest to set EchoTime only if it does not exist, perhaps, at line 214-218. And do not forget to use ms rather than second.

@tiborauer

Copy link
Copy Markdown
Member

Testing

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

Ok, I added a check for EchoTime( and RepetitionTime as well) around line 214 and create the fields in the header if they don't exist. I've tested this on our strange philips dicoms as well as our siemens dicoms and it looks like it runs correctly.

Pushed to my fork and updated the PR.

@tiborauer

Copy link
Copy Markdown
Member

Final PR to you PR has been sent. I think it is ready to be merged with this modification - if you also agree.

@jones-michael-s

Copy link
Copy Markdown
Collaborator Author

Merged.

@tiborauer
tiborauer merged commit ee48221 into automaticanalysis:master Jan 22, 2019
@jones-michael-s
jones-michael-s deleted the philips_dicom_tweak branch June 4, 2021 16:55
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

Successfully merging this pull request may close these issues.

2 participants