Scale transformation shouldn't return NAs in event of constant input
If constant input is passed to the `Scale` transformation, a column of N/A values is returned. This should probably just fail with an exception (or at minimum, return a column of `0`).
diff --git a/bids/analysis/tests/test_transformations.py b/bids/analysis/tests/test_transformations.py
index cc3126dd..63eecaa3 100644
--- a/bids/analysis/tests/test_transformations.py
+++ b/bids/analysis/tests/test_transformations.py
@@ -128,7 +128,7 @@ def test_sum(collection):
                       output='sum', weights=[1, 1, 1])
 
 
-def test_scale(collection):
+def test_scale(collection, sparse_run_variable_with_missing_values):
     transform.Scale(collection, variables=['RT', 'parametric gain'],
                     output=['RT_Z', 'gain_Z'], groupby=['run', 'subject'])
     groupby = collection['RT'].get_grouper(['run', 'subject'])
@@ -137,6 +137,16 @@ def test_scale(collection):
         groupby).apply(lambda x: (x - x.mean()) / x.std())
     assert np.allclose(z1, z2)
 
+    # Test constant input
+    coll = sparse_run_variable_with_missing_values
+    coll['var'].values.fillna(1)
+    with pytest.raises(ValueError, match="Cannot scale.*1.0"):
+        transform.Scale(coll, 'var').values
+    with pytest.raises(ValueError, match="Cannot scale.*1.0"):
+        transform.Scale(coll, 'var', replace_na='before').values
+    transform.Scale(coll, 'var', replace_na='after', output='zero')
+    assert coll['zero'].values.unique() == 0
+
 
 def test_demean(collection):
     transform.Demean(collection, variables=['RT'], output=['RT_dm'])
diff --git a/bids/analysis/transformations/compute.py b/bids/analysis/transformations/compute.py
index 80f6232f..4c06a354 100644
--- a/bids/analysis/transformations/compute.py
+++ b/bids/analysis/transformations/compute.py
@@ -138,9 +138,19 @@ class Scale(Transformation):
         None, no replacement is performed. If 'before', missing values are
         replaced with 0's before scaling. If 'after', missing values are
         replaced with 0 after scaling.
+
+    Notes
+    -----
+    If a constant column is passed in, and replace_na is None or 'before', an
+    exception will be raised.
     """
 
     def _transform(self, data, demean=True, rescale=True, replace_na=None):
+        if data.nunique() == 1 and replace_na in {None, 'before'}:
+            val = data.unique()[0]
+            raise ValueError("Cannot scale a column with constant value ({})! "
+                             "If you want a constant column of 0's returned, "
+                             "set replace_na to 'after'.".format(val))
         if replace_na == 'before':
             data = data.fillna(0.)
         if demean:
['bids/analysis/tests/test_transformations.py', 'bids/analysis/transformations/compute.py']