Skip to content

Commit

Permalink
[FIX] Fixes logger error w/reports
Browse files Browse the repository at this point in the history
The returned reports were true but because we were calling
images.coerce_atlas_to_dict() multiple times the logger was being
called multiple times to report what type of atlas was provided.
  • Loading branch information
rmarkello committed May 31, 2021
1 parent ce39488 commit 0f95267
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions abagen/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,16 @@ def coerce_atlas_to_dict(atlas, donors, atlas_info=None, data_dir=None):
if len(missing) > 0:
raise ValueError('Provided `atlas` does not have entry for all '
f'requested donors. Missing donors: {donors}.')
LGR.info('Donor-specific atlases provided; using native coords for '
'tissue samples')
except AttributeError:
atlas = check_atlas(atlas, atlas_info)
atlas = {donor: atlas for donor in donors}

if group_atlas:
LGR.info('Group-level atlas provided; using MNI coords for '
'tissue samples')
else:
LGR.info('Donor-specific atlases provided; using native coords for '
'tissue samples')

# update group atlas status based on what was decided / derived
for atl in atlas.values():
Expand Down
10 changes: 9 additions & 1 deletion abagen/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
<https://creativecommons.org/publicdomain/zero/1.0/>`_.
"""

import logging

import numpy as np

from . import __version__
from .datasets import check_donors, fetch_donor_info
from .images import coerce_atlas_to_dict
from .utils import first_entry


LGR = logging.getLogger('abagen')
METRICS = {
np.mean: 'mean',
np.median: 'median'
Expand Down Expand Up @@ -65,6 +67,10 @@ def __init__(self, atlas, atlas_info=None, *, ibf_threshold=0.5,
region_agg='donors', agg_metric='mean', corrected_mni=True,
reannotated=True, donors='all', return_donors=False,
data_dir=None, counts=None, n_probes=None, n_genes=None):

efflevel = LGR.getEffectiveLevel()
LGR.setLevel(100)

atlas, self.group_atlas = \
coerce_atlas_to_dict(atlas, donors, atlas_info=atlas_info,
data_dir=data_dir)
Expand All @@ -91,6 +97,8 @@ def __init__(self, atlas, atlas_info=None, *, ibf_threshold=0.5,
self.n_genes = n_genes
self.body = self.gen_report()

LGR.setLevel(efflevel)

def gen_report(self):
""" Generates main text of report
"""
Expand Down

0 comments on commit 0f95267

Please sign in to comment.