You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was peeking around the code again (debugging some issues on my side), and was trying to inspect the Derivatives instance created during my nibabies run.
However, the current __repr__ method only shows attributes (with matching keys in self.names) that have non-None values. This was confusing, because those attributes are always initially set to None, and only get populated once the populate method is called.. When everything is None, it appears as if the entire Derivatives instance is None:
class DerivativesMain:
def __init__(self, bids_root):
self.names = dict(t1w_mask=dict(), t2w_mask=dict(), t1w_aseg=dict(), t2w_aseg=dict())
for name in self.names:
setattr(self, name, None)
def __repr__(self):
return '\n'.join([name for name in self.names if getattr(self, name)])
foo = DerivativesMain("foo")
foo
>
Proposed change
Always include information about attributes with matching keys in self.names, regardless of their current value, in the repr string:
Code
class DerivativesPR:
def __init__(self, bids_root):
self.names = dict(t1w_mask=dict(), t2w_mask=dict(), t1w_aseg=dict(), t2w_aseg=dict())
for name in self.names:
setattr(self, name, None)
def __repr__(self):
return '\n'.join(f"{attr}: {getattr(self, attr)}" for attr in self.names)
This representation would make it easier to verify the values for the expected attributes, helping in debugging (and in my case, I would have immediately known that I had done something wrong on my end 🙂 )
If this sounds reasonable to you, I can start a PR.
The text was updated successfully, but these errors were encountered:
Hello,
I was peeking around the code again (debugging some issues on my side), and was trying to inspect the
Derivatives
instance created during my nibabies run.However, the current
__repr__
method only shows attributes (with matching keys inself.names
) that have non-None
values. This was confusing, because those attributes are always initially set toNone
, and only get populated once thepopulate
method is called.. When everything isNone
, it appears as if the entireDerivatives
instance isNone
:nibabies/nibabies/utils/bids.py
Lines 69 to 70 in 1829514
Current behavior (toy example):
Code
Proposed change
Always include information about attributes with matching keys in
self.names
, regardless of their current value, in the repr string:Code
This representation would make it easier to verify the values for the expected attributes, helping in debugging (and in my case, I would have immediately known that I had done something wrong on my end 🙂 )
If this sounds reasonable to you, I can start a PR.
The text was updated successfully, but these errors were encountered: