Skip to content

Commit d8e4c6e

Browse files
committed
fix: resolve conflict in CHANGES
2 parents 57be511 + 711c564 commit d8e4c6e

35 files changed

+344
-219
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nipy/COMMIT_INFO.txt export-subst

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Changes since 0.5
22
=================
33

44
* API: Node now allows specifying node level configuration for SGE/PBS clusters
5+
* API: Logging to file is disabled by default
6+
* API: New location of log file -> .nipype/nipype.cfg
7+
8+
* ENH: Changing logging options via config works for distributed processing
59

610
Release 0.5 (Mar 10, 2012)
711
==========================

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include Makefile
77
include build_docs.py
88
include setup_egg.py
99
include doc/documentation.zip
10+
include nipype/COMMIT_INFO.txt
1011

1112
recursive-include doc *
1213
recursive-include matlabscripts *

doc/users/config_file.rst

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
Some of the system wide options of Nipype can be configured using a
88
configuration file. Nipype looks for the file in the local folder under the name
9-
``nipype.cfg`` and in ``~/.nipype.cfg`` (in this order). If an option will not
10-
be specified a default value will be assumed. The file is divided into following
11-
sections:
9+
``nipype.cfg`` and in ``~/.nipype/nipype.cfg`` (in this order). If an option
10+
will not be specified a default value will be assumed. The file is divided into
11+
following sections:
1212

1313
Logging
1414
~~~~~~~
@@ -25,7 +25,7 @@ Logging
2525
values: ``INFO`` and ``DEBUG``; default value: ``INFO``)
2626
*log_to_file*
2727
Indicates whether logging should also send the output to a file (possible
28-
values: ``true`` and ``false``; default value: ``true``)
28+
values: ``true`` and ``false``; default value: ``false``)
2929
*log_directory*
3030
Where to store logs. (string, default value: home directory)
3131
*log_size*
@@ -120,43 +120,52 @@ Example
120120
hash_method = timestamp
121121
display_variable = :1
122122

123-
Additionally you can set some config options by setting the workflow.config. This, however, currently does not work for options related to logging levels. Those will be always read from .cfg files.
124-
125-
Workflow.config property has a form of a nested dictionary reflecting the structure of the .cfg file.
123+
Workflow.config property has a form of a nested dictionary reflecting the
124+
structure of the .cfg file.
126125

127126
::
128127
129128
myworkflow = pe.Workflow()
130129
myworkflow.config['execution'] = {'stop_on_first_rerun': 'True',
131130
'hash_method': 'timestamp'}
132131

133-
You can also directly set config options in your workflow script. An
132+
You can also directly set global config options in your workflow script. An
134133
example is shown below. This needs to be called before you import the
135134
pipeline or the logger. Otherwise logging level will not be reset.
136135

137136
::
138137

139-
from nipype.utils.config import config
140-
from StringIO import StringIO
141-
cfg = StringIO("""
142-
[logging]
143-
workflow_level = DEBUG
138+
from nipype import config
139+
cfg = dict(logging=dict(workflow_level = 'DEBUG'),
140+
execution={'stop_on_first_crash': False,
141+
'hash_method': 'content'})
142+
config.update_config(cfg)
144143

145-
[execution]
146-
stop_on_first_crash = false
147-
hash_method = content
148-
""")
149-
150-
config.readfp(cfg)
144+
Enabling logging to file
145+
~~~~~~~~~~~~~~~~~~~~~~~~
146+
147+
By default, logging to file is disabled. One can enable and write the file to
148+
a location of choice as in the example below.
149+
150+
::
151+
152+
import os
153+
from nipype import config, logging
154+
config.update_config({'logging': {'log_directory': os.getcwd(),
155+
'log_to_file': True}})
156+
logging.update_logging(config)
157+
158+
The logging update line is necessary to change the behavior of logging such as
159+
output directory, logging level, etc.,.
151160

152161
Debug configuration
153162
~~~~~~~~~~~~~~~~~~~
154163

155-
To enable debug mode, one can insert the following lines at the beginning of any
156-
script.::
164+
To enable debug mode, one can insert the following lines::
157165

158-
from nipype.utils.config import config
166+
from nipype import config, logging
159167
config.enable_debug_mode()
168+
logging.update_logging(config)
160169

161170
In this mode the following variables are set::
162171

nipype/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
URL as __url__,
77
STATUS as __status__,
88
__version__)
9-
from utils.config import config
9+
from utils.config import NipypeConfig
10+
config = NipypeConfig()
11+
from utils.logger import Logging
12+
logging = Logging(config)
1013

1114
# We require numpy 1.2 for our test suite. If Tester fails to import,
1215
# check the version of numpy the user has and inform them they need to

nipype/algorithms/misc.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,30 @@
2424
import scipy.io as sio
2525
import itertools
2626

27-
from nipype.utils.config import config
27+
from .. import config, logging
2828
import matplotlib
2929
matplotlib.use(config.get("execution", "matplotlib_backend"))
3030
import matplotlib.pyplot as plt
3131

32-
from nipype.interfaces.base import (BaseInterface, traits, TraitedSpec, File,
33-
InputMultiPath, OutputMultiPath,
34-
BaseInterfaceInputSpec, isdefined)
35-
from nipype.utils.filemanip import fname_presuffix, split_filename
36-
import logging
37-
38-
logging.basicConfig()
32+
from ..interfaces.base import (BaseInterface, traits, TraitedSpec, File,
33+
InputMultiPath, OutputMultiPath,
34+
BaseInterfaceInputSpec, isdefined)
35+
from ..utils.filemanip import fname_presuffix, split_filename
3936
iflogger = logging.getLogger('interface')
4037

4138

4239
class PickAtlasInputSpec(BaseInterfaceInputSpec):
43-
atlas = File(exists=True, desc="Location of the atlas that will be used.", mandatory=True)
40+
atlas = File(exists=True, desc="Location of the atlas that will be used.",
41+
mandatory=True)
4442
labels = traits.Either(traits.Int, traits.List(traits.Int),
45-
desc="Labels of regions that will be included in the mask. Must be \
46-
compatible with the atlas used.", compulsory=True)
47-
hemi = traits.Enum('both', 'left', 'right', desc="Restrict the mask to only one hemisphere: left or right", usedefault=True)
48-
dilation_size = traits.Int(desc="Defines how much the mask will be dilated (expanded in 3D).", usedefault=True)
43+
desc=("Labels of regions that will be included in"
44+
"the mask. Must be compatible with the atlas used."),
45+
compulsory=True)
46+
hemi = traits.Enum('both', 'left', 'right',
47+
desc="Restrict the mask to only one hemisphere: left or right",
48+
usedefault=True)
49+
dilation_size = traits.Int(usedefault=True,
50+
desc="Defines how much the mask will be dilated (expanded in 3D).")
4951
output_file = File(desc="Where to store the output mask.")
5052

5153

nipype/algorithms/modelgen.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
traits, File, Bunch, BaseInterfaceInputSpec,
3030
isdefined)
3131
from nipype.utils.filemanip import filename_to_list
32-
from nipype.utils.logger import iflogger
33-
from nipype.utils.config import config
34-
32+
from .. import config, logging
33+
iflogger = logging.getLogger('interface')
3534

3635
def gcd(a, b):
3736
"""Returns the greatest common divisor of two integers

nipype/algorithms/rapidart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from scipy import signal
2727
import scipy.io as sio
2828

29-
from nipype.utils.config import config
29+
from .. import config
3030
import matplotlib
3131
matplotlib.use(config.get("execution", "matplotlib_backend"))
3232
import matplotlib.pyplot as plt

nipype/caching/tests/test_memory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
from nipype.caching import Memory
1010
from nipype.pipeline.tests.test_engine import TestInterface
11-
from nipype.utils.config import config
11+
from nipype.utils.config import NipypeConfig
12+
config = NipypeConfig()
13+
config.set_default_config()
1214

1315
nb_runs = 0
1416

nipype/interfaces/ants/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from nipype.interfaces.base import (CommandLine, CommandLineInputSpec, traits,
77
isdefined)
88

9-
import logging
9+
from ... import logging
1010
logger = logging.getLogger('iflogger')
1111

1212

nipype/interfaces/ants/setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ def configuration(parent_package='',top_path=None):
55

66
config = Configuration('ants', parent_package, top_path)
77

8-
config.add_data_dir('tests')
9-
108
return config
119

1210
if __name__ == '__main__':

nipype/interfaces/base.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
from time import time
2222
from warnings import warn
2323

24-
from nipype.interfaces.traits_extension import (traits, Undefined, TraitDictObject,
25-
TraitListObject, TraitError,
26-
isdefined, File, Directory,
27-
has_metadata)
28-
from nipype.utils.filemanip import (md5, hash_infile, FileNotFoundError,
29-
hash_timestamp)
30-
from nipype.utils.misc import is_container
31-
from nipype.utils.config import config
32-
from nipype.utils.logger import iflogger
33-
from nipype.utils.misc import trim
24+
from .traits_extension import (traits, Undefined, TraitDictObject,
25+
TraitListObject, TraitError,
26+
isdefined, File, Directory,
27+
has_metadata)
28+
from ..utils.filemanip import (md5, hash_infile, FileNotFoundError,
29+
hash_timestamp)
30+
from ..utils.misc import is_container, trim
31+
from .. import config, logging
32+
33+
iflogger = logging.getLogger('interface')
3434

3535

3636
__docformat__ = 'restructuredtext'

nipype/interfaces/cmtk/cmtk.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
import nibabel as nb
2121
import networkx as nx
2222
import sys
23-
import logging
2423

25-
logging.basicConfig()
24+
from ... import logging
2625
iflogger = logging.getLogger('interface')
2726

2827
def length(xyz, along=False):

nipype/interfaces/cmtk/nx.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
import networkx as nx
1919
import scipy.io as sio
2020
import pickle
21-
import logging
2221
from nipype.utils.misc import package_check
23-
from nipype.workflows.misc.utils import get_data_dims
2422
import warnings
2523

26-
logging.basicConfig()
24+
from ... import logging
2725
iflogger = logging.getLogger('interface')
2826

2927
have_cmp = True

nipype/interfaces/cmtk/parcellation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
import shutil
1919
from nipype.utils.misc import package_check
2020
import warnings
21-
import logging
2221

23-
logging.basicConfig()
22+
from ... import logging
2423
iflogger = logging.getLogger('interface')
2524

2625
have_cmp = True

nipype/interfaces/dipy/tracks.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
from nipype.interfaces.base import (TraitedSpec, BaseInterface, BaseInterfaceInputSpec,
33
File, isdefined, traits)
44
from nipype.utils.filemanip import split_filename
5-
import os, os.path as op
5+
import os.path as op
66
import nibabel as nb, nibabel.trackvis as trk
7-
import numpy as np
8-
import logging
97
from nipype.utils.misc import package_check
108
import warnings
119

12-
logging.basicConfig()
10+
from ... import logging
1311
iflogger = logging.getLogger('interface')
1412

1513
try:

nipype/interfaces/fsl/model.py

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ class MultipleRegressDesign(BaseInterface):
984984
Examples
985985
--------
986986
987-
>>> from nipype.interfaces.fsl import L2Model
987+
>>> from nipype.interfaces.fsl import MultipleRegressDesign
988988
>>> model = MultipleRegressDesign()
989989
>>> model.inputs.contrasts = [['group mean', 'T',['reg1'],[1]]]
990990
>>> model.inputs.regressors = dict(reg1=[1, 1, 1], reg2=[2.,-4, 3])
@@ -1410,7 +1410,7 @@ class RandomiseInputSpec(FSLCommandInputSpec):
14101410
mask = File(exists=True, desc='mask image', argstr='-m %s')
14111411
x_block_labels = File(exists=True, desc='exchangeability block labels file', argstr='-e %s')
14121412
demean = traits.Bool(desc='demean data temporally before model fitting', argstr='-D')
1413-
one_sample_group_mean = traits.Bool(desc='perform 1-sample group-mean test instead of generic permutation test',
1413+
one_sample_group_mean = traits.Bool(desc='perform 1-sample group-mean test instead of generic permutation test',
14141414
argstr='-l')
14151415
show_total_perms = traits.Bool(desc='print out how many unique permutations would be generated and exit',
14161416
argstr='-q')
@@ -1442,7 +1442,24 @@ class RandomiseInputSpec(FSLCommandInputSpec):
14421442

14431443

14441444
class RandomiseOutputSpec(TraitedSpec):
1445-
tstat1_file = File(exists=True, desc='path/name of tstat image corresponding to the first t contrast')
1445+
tstat_files = traits.List(
1446+
File(exists=True),
1447+
desc='t contrast raw statistic')
1448+
fstat_files = traits.List(
1449+
File(exists=True),
1450+
desc='f contrast raw statistic')
1451+
t_p_files = traits.List(
1452+
File(exists=True),
1453+
desc='f contrast uncorrected p values files')
1454+
f_p_files = traits.List(
1455+
File(exists=True),
1456+
desc='f contrast uncorrected p values files')
1457+
t_corrected_p_files = traits.List(
1458+
File(exists=True),
1459+
desc='t contrast FWE (Family-wise error) corrected p values files')
1460+
f_corrected_p_files = traits.List(
1461+
File(exists=True),
1462+
desc='f contrast FWE (Family-wise error) corrected p values files')
14461463

14471464

14481465
class Randomise(FSLCommand):
@@ -1470,5 +1487,34 @@ class Randomise(FSLCommand):
14701487

14711488
def _list_outputs(self):
14721489
outputs = self.output_spec().get()
1473-
outputs['tstat1_file'] = self._gen_fname(self.inputs.base_name, suffix='_tstat1')
1490+
outputs['tstat_files'] = glob(os.path.join(
1491+
os.getcwd(),
1492+
'%s_tstat*.nii' % self.inputs.base_name))
1493+
outputs['fstat_files'] = glob(os.path.join(
1494+
os.getcwd(),
1495+
'%s_fstat*.nii' % self.inputs.base_name))
1496+
prefix = False
1497+
if self.inputs.tfce or self.inputs.tfce2D:
1498+
prefix = 'tfce'
1499+
elif self.inputs.vox_p_values:
1500+
prefix = 'vox'
1501+
elif self.inputs.c_thresh or self.inputs.f_c_thresh:
1502+
prefix = 'clustere'
1503+
elif self.inputs.cm_thresh or self.inputs.f_cm_thresh:
1504+
prefix = 'clusterm'
1505+
if prefix:
1506+
outputs['t_p_files'] = glob(os.path.join(
1507+
os.getcwd(),
1508+
'%s_%s_p_tstat*.nii' % (self.inputs.base_name, prefix)))
1509+
outputs['t_corrected_p_files'] = glob(os.path.join(
1510+
os.getcwd(),
1511+
'%s_%s_corrp_tstat*.nii' % (self.inputs.base_name, prefix)))
1512+
1513+
outputs['f_p_files'] = glob(os.path.join(
1514+
os.getcwd(),
1515+
'%s_%s_p_fstat*.nii' % (self.inputs.base_name, prefix)))
1516+
outputs['f_corrected_p_files'] = glob(os.path.join(
1517+
os.getcwd(),
1518+
'%s_%s_corrp_fstat*.nii' % (self.inputs.base_name, prefix)))
1519+
14741520
return outputs

nipype/interfaces/io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from nipype.utils.filemanip import (copyfile, list_to_filename,
3939
filename_to_list)
4040

41-
import logging
41+
from .. import logging
4242
iflogger = logging.getLogger('interface')
4343

4444

@@ -130,6 +130,8 @@ class DataSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
130130

131131
def __setattr__(self, key, value):
132132
if key not in self.copyable_trait_names():
133+
if not isdefined(value):
134+
super(DataSinkInputSpec, self).__setattr__(key, value)
133135
self._outputs[key] = value
134136
else:
135137
if key in self._outputs:

0 commit comments

Comments
 (0)