diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h b/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h
index be20364dab0bef32d67d4f4604235293eb4ae92a..83bde1478e29552010959772cbbc05631c1b20c6 100644
--- a/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h
+++ b/Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h
@@ -99,7 +99,9 @@ namespace Mantid
 
       signal_t getSignalAtVMD(const Mantid::Kernel::VMD & coords,
           const Mantid::API::MDNormalization & normalization = Mantid::API::VolumeNormalization) const;
-
+      
+      /// Setter for the masking region.
+      virtual void setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion) = 0;
     };
     
     /// Shared pointer to the IMDWorkspace base class
diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h b/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h
index e7973f5ebf4e096b7050d5bc7534330ab2a24cf4..6047cfc59c3f70fba48b513d375e87e486d83a76 100644
--- a/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h
+++ b/Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h
@@ -295,6 +295,8 @@ namespace Mantid
       void saveInstrumentNexus(::NeXus::File * file) const;
       void loadInstrumentNexus(::NeXus::File * file);
 
+       //Apply masking.
+       void setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion);
 
     protected:
       MatrixWorkspace(Mantid::Geometry::INearestNeighboursFactory* factory = new Mantid::Geometry::NearestNeighboursFactory);
diff --git a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
index c828b290660b7037e2ad6bd0cef1ebb8fcf324f7..571e176ef785221f95d9691194736b2dc969ee93 100644
--- a/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
+++ b/Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
@@ -1748,6 +1748,15 @@ namespace Mantid
       file->closeGroup();
     }
 
+    /*
+    MDMasking for a Matrix Workspace has not been implemented.
+    @param : 
+    */
+    void  MatrixWorkspace::setMDMasking(Mantid::Geometry::MDImplicitFunction*)
+    {
+      throw std::runtime_error("MatrixWorkspace::setMDMasking has no implementation");
+    }
+
 
   } // namespace API
 } // Namespace Mantid
diff --git a/Code/Mantid/Framework/API/test/MatrixWorkspaceTest.h b/Code/Mantid/Framework/API/test/MatrixWorkspaceTest.h
index c1e42b56cf9f95c59fb981bf2c2f98303b25fca8..3b1b0ba8e5e429bc9f1fe320b27c4bbf262556b7 100644
--- a/Code/Mantid/Framework/API/test/MatrixWorkspaceTest.h
+++ b/Code/Mantid/Framework/API/test/MatrixWorkspaceTest.h
@@ -620,7 +620,11 @@ public:
     TS_ASSERT_DELTA(ws->getSignalAtCoord(coords, Mantid::API::NoNormalization), 11.0, 1e-5);
   }
 
-
+  void test_setMDMasking()
+  {
+    boost::shared_ptr<MatrixWorkspace> ws(new WorkspaceTester());
+    TSM_ASSERT_THROWS("Characterisation test. This is not implemented.", ws->setMDMasking(NULL), std::runtime_error);
+  }
 
 private:
   boost::shared_ptr<MatrixWorkspace> ws;
diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompositeImplicitFunction.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompositeImplicitFunction.h
index 7785f0ba6bfefa8d19afa6ff1d1a0ac4788a14fe..e7766b7af2188445020f9ac741c4610f0f1201f9 100644
--- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompositeImplicitFunction.h
+++ b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompositeImplicitFunction.h
@@ -59,13 +59,10 @@ public:
   std::string getName() const;
   std::string toXMLString() const;
   int getNFunctions() const;
-  bool operator==(const CompositeImplicitFunction &other) const;
-  bool operator!=(const CompositeImplicitFunction &other) const;
   static std::string functionName()
   {
     return "CompositeImplicitFunction";
   }
-  std::vector<Mantid::Geometry::MDImplicitFunction_sptr > getFunctions() const;
 protected:
   std::vector<Mantid::Geometry::MDImplicitFunction_sptr > m_Functions;
   typedef std::vector<Mantid::Geometry::MDImplicitFunction_sptr >::const_iterator
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/CompositeImplicitFunction.cpp b/Code/Mantid/Framework/MDAlgorithms/src/CompositeImplicitFunction.cpp
index b8db684c02bb59e1a25daf500ef0d37956bef170..de64edbbbba15912f94a645b4e407e5b101dc043 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/CompositeImplicitFunction.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/CompositeImplicitFunction.cpp
@@ -106,44 +106,6 @@ namespace Mantid
           return evalResult;
         }
 
-        /** Comparison operator */
-        bool CompositeImplicitFunction::operator==(const CompositeImplicitFunction &other) const
-        {
-
-            bool evalResult = false;
-            if(other.getNFunctions() != this->getNFunctions() )
-            {
-                evalResult = false;
-            }
-            else if(other.getNFunctions() == 0)
-            {
-                evalResult = false;
-            }
-            else
-            {
-                for(size_t i = 0; i < this->m_Functions.size(); i++)
-                {
-                    evalResult = false; //TODO call equals operations on nested implicit functions.
-                    if(!evalResult)
-                    {
-                        break;
-                    }
-                }
-            }
-            return evalResult;
-        }
-
-        //TODO. retire this function, call evaluate instead!
-        std::vector<Mantid::Geometry::MDImplicitFunction_sptr > CompositeImplicitFunction::getFunctions() const
-        {
-          return this->m_Functions;
-        }
-            
-        bool CompositeImplicitFunction::operator!=(const CompositeImplicitFunction &other) const
-        {
-            return !(*this == other);
-        }
-
 
     }
 }
diff --git a/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionTest.h b/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionTest.h
index 005891974e34272fbde0f926ef5cc81ac0f0b7e6..f9588f401a21587104b2e8c031b31a614fca58ba 100644
--- a/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionTest.h
+++ b/Code/Mantid/Framework/MDAlgorithms/test/CompositeImplicitFunctionTest.h
@@ -79,44 +79,6 @@ public:
     TSM_ASSERT_EQUALS("The xml generated by this function did not match the expected schema.", "<Function><Type>CompositeImplicitFunction</Type><ParameterList/><Function></Function><Function></Function></Function>", function.toXMLString());
   }
 
-  void testNotEqual()
-  {
-    using namespace Mantid::MDAlgorithms;
-
-    CompositeImplicitFunction A;
-    CompositeImplicitFunction B;
-    CompositeImplicitFunction C;
-    C.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(new MockImplicitFunction));
-    TSM_ASSERT_DIFFERS("These two objects should not be considered equal as they both have zero nested functions.", A, B);
-    TSM_ASSERT_DIFFERS("These two objects should not be considered equal as they have and unequal number of nested functions.", A, C);		
-  }
-
-  void testReturnNestedFunctions() //Test access to nested functions.
-  {
-    using namespace Mantid::MDAlgorithms;
-    CompositeImplicitFunction function;
-
-    MockImplicitFunction* mockFunctionA = new MockImplicitFunction;
-    MockImplicitFunction* mockFunctionB = new MockImplicitFunction;
-    MockImplicitFunction* mockFunctionC = new MockImplicitFunction;
-    EXPECT_CALL(*mockFunctionA, getName()).Times(1).WillOnce(testing::Return("A"));
-    EXPECT_CALL(*mockFunctionB, getName()).Times(1).WillOnce(testing::Return("B"));
-    EXPECT_CALL(*mockFunctionC, getName()).Times(1).WillOnce(testing::Return("C"));
-
-    function.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(mockFunctionA));
-    function.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(mockFunctionB));
-    function.addFunction(Mantid::Geometry::MDImplicitFunction_sptr(mockFunctionC));
-
-    std::vector<Mantid::Geometry::MDImplicitFunction_sptr > returnedFuncs = function.getFunctions();
-    std::vector<Mantid::Geometry::MDImplicitFunction_sptr >::const_iterator it = returnedFuncs.begin();
-
-    TSM_ASSERT_EQUALS("The returned function did not match input function type", (*it)->getName(), "A" );
-    it++;
-    TSM_ASSERT_EQUALS("The returned function did not match input function type", (*it)->getName(), "B"  );
-    it++;
-    TSM_ASSERT_EQUALS("The returned function did not match input function type", (*it)->getName(), "C"  );
-  }
-
   void testCannotAddNullDimension()
   {
     using namespace Mantid::MDAlgorithms;
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/IMDBox.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/IMDBox.h
index 925cc41306db24f7bf354bde81e209369aa49629..dff3c9d13bb646c88b27b626f2750374bc97c4f6 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/IMDBox.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/IMDBox.h
@@ -61,6 +61,12 @@ namespace MDEvents
     /// Getter for the masking
     virtual bool getIsMasked() const = 0;
 
+    ///Setter for masking the box
+    virtual void mask() = 0;
+
+    ///Setter for unmasking the box
+    virtual void unmask() = 0;
+
     // ----------------------------- ISaveable Methods ------------------------------------------------------
 
     /// Save the data - to be overriden
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
index a8fc0d20a514366b80aca43428bffdc0cff45245..f2d77531bcae2af6cc60ff628d37b3546504a7e4 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
@@ -201,6 +201,12 @@ namespace MDEvents
 
     void transformDimensions(std::vector<double> & scaling, std::vector<double> & offset);
 
+    ///Setter for masking the box
+    void mask();
+
+    ///Setter for unmasking the box
+    void unmask();
+
   protected:
 
     inline void loadEvents() const;
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h
index 149deb0e05a55d39779b222e36b9006bc07dbf15..5db1123746b02497c45e5fbd7c86601296bbe2e7 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDEventWorkspace.h
@@ -136,6 +136,8 @@ namespace MDEvents
       data = box;
     }
 
+    //Apply masking.
+    void setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion);
 
   protected:
 
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
index f44224fd494afe0f07fdef2d81836fad91f741f5..aeaa846efe7904fefeb3287c35c258544d3d1d54 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
@@ -110,6 +110,12 @@ namespace MDEvents
 
     virtual bool getIsMasked() const;
 
+    ///Setter for masking the box
+    virtual void mask();
+
+    ///Setter for unmasking the box
+    virtual void unmask();
+
   public:
     /// Typedef for a shared pointer to a MDGridBox
     typedef boost::shared_ptr< MDGridBox<MDE, nd> > sptr;
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h
index 2d132479aff97c218102fda7522f51fb176897bb..2e7244a6ad57410e84bde0893434b9ebc4832f57 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDHistoWorkspace.h
@@ -351,8 +351,8 @@ namespace MDEvents
     virtual std::vector<signal_t> getSignalDataVector() const;
     virtual std::vector<signal_t> getErrorDataVector() const;
 
-
-
+    //Apply masking.
+    void setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion);
 
   private:
 
diff --git a/Code/Mantid/Framework/MDEvents/src/MDBox.cpp b/Code/Mantid/Framework/MDEvents/src/MDBox.cpp
index 81e148a43a1338c78928dd623b3de4ad7e60b05a..d1ca4cd4e890e94e3e8d2add8bb55cc23fc75b89 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDBox.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDBox.cpp
@@ -758,6 +758,20 @@ namespace MDEvents
     this->releaseEvents();
   }
 
+    ///Setter for masking the box
+  TMDE(
+  void MDBox)::mask()
+  {
+    m_bIsMasked = true;
+  }
+
+  ///Setter for unmasking the box
+  TMDE(
+  void MDBox)::unmask()
+  {
+    m_bIsMasked = false;
+  }
+
 
 
 }//namespace MDEvents
diff --git a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
index 0dbf3dbdc27610f9dc4103ae60e00b8f212f0ed1..ed4c90367669dde57a86bc223fdad58a6ac6b2a6 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp
@@ -17,6 +17,7 @@
 #include "MantidMDEvents/MDSplitBox.h"
 #include <iomanip>
 #include <functional>
+#include <algorithm>
 #include "MantidMDEvents/MDBoxIterator.h"
 #include "MantidKernel/Memory.h"
 
@@ -726,6 +727,34 @@ namespace MDEvents
     x.push_back(  (end-start).norm() );
   }
 
+  /**
+  Setter for the masking region. 
+  Masking is not a compound operation. Old masks will be cleared when calling this.
+  @param maskingRegion : Implicit function defining mask region.
+  */
+  TMDE(
+  void MDEventWorkspace)::setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion)
+  {
+    std::vector<IMDBox<MDE,nd> *> toMaskBoxes;
+    std::vector<IMDBox<MDE,nd> *> allBoxes;
+    std::vector<IMDBox<MDE,nd> *> toNotMaskBoxes;
+    
+    //Clear old masks
+    this->data->getBoxes(allBoxes, 10000, true);
+    for(size_t i = 0; i < allBoxes.size(); ++i)
+    {
+      allBoxes[i]->unmask();
+    }
+
+    //Apply new masks
+    this->data->getBoxes(toMaskBoxes, 10000, true, maskingRegion);
+    for(size_t i = 0; i < toMaskBoxes.size(); ++i)
+    {
+      toMaskBoxes[i]->mask();
+    }
+
+    delete maskingRegion;
+  }
 
 }//namespace MDEvents
 
diff --git a/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp b/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp
index 21cbe097cb5be7360411d693aa9a93eece1591c7..adbb0d40421c0ee10364a6ca7e95bdc199e86ee7 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp
@@ -1422,6 +1422,29 @@ namespace MDEvents
     return isMasked;
   }
 
+  ///Setter for masking the box
+  TMDE(
+  void MDGridBox)::mask()
+  {
+    for (size_t i=0; i < numBoxes; ++i)
+    {
+      // Go through each contained box
+      IMDBox<MDE, nd> * box = boxes[i];
+      box->mask();
+    }
+  }
+
+  ///Setter for unmasking the box
+  TMDE(
+  void MDGridBox)::unmask()
+  {
+    for (size_t i=0; i < numBoxes; ++i)
+    {
+      // Go through each contained box
+      IMDBox<MDE, nd> * box = boxes[i];
+      box->unmask();
+    }
+  }
 
 }//namespace MDEvents
 
diff --git a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
index ffaf1930a49693a08a0e4e74df7d3ca4d07523db..453deefeeec904146be5dfed557620ef3d636cfb 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDHistoWorkspace.cpp
@@ -1162,6 +1162,16 @@ namespace MDEvents
     }
   }
 
+  /**
+  Setter for the masking region. 
+  @param maskingRegion : Implicit function defining mask region.
+  */
+  void MDHistoWorkspace::setMDMasking(Mantid::Geometry::MDImplicitFunction* maskingRegion)
+  {
+    UNUSED_ARG(maskingRegion);
+    throw std::runtime_error("MDHistoWorkspace::setMDMasking not implemented yet.");
+  }
+
 
 } // namespace Mantid
 } // namespace MDEvents
diff --git a/Code/Mantid/Framework/MDEvents/test/IMDBoxTest.h b/Code/Mantid/Framework/MDEvents/test/IMDBoxTest.h
index 4f53db285cbf97dacca74806b188bb0f387ea1bc..38202ba028846f5b26a10db1aa8d0f1dff0b7a26 100644
--- a/Code/Mantid/Framework/MDEvents/test/IMDBoxTest.h
+++ b/Code/Mantid/Framework/MDEvents/test/IMDBoxTest.h
@@ -89,6 +89,16 @@ public:
     throw std::runtime_error("IMDBoxTester does not implement getIsMasked");
   }
 
+  virtual void mask()
+  {
+    throw std::runtime_error("IMDBoxTester does not implement mask");
+  }
+
+  virtual void unmask()
+  {
+    throw std::runtime_error("IMDBoxTester does not implement unmask");
+  }
+
   uint64_t getFilePosition() const
   { return m_filePos; }
   uint64_t m_filePos;
diff --git a/Code/Mantid/Framework/MDEvents/test/MDBoxTest.h b/Code/Mantid/Framework/MDEvents/test/MDBoxTest.h
index 78974fb1b51ab98fecaf0d0d41c88eb2e67d528a..a6dda8417edae7bd304ed2526c808b5b7f8daf1e 100644
--- a/Code/Mantid/Framework/MDEvents/test/MDBoxTest.h
+++ b/Code/Mantid/Framework/MDEvents/test/MDBoxTest.h
@@ -1063,6 +1063,22 @@ public:
     MDBox<MDLeanEvent<1>, 1> box;
     TSM_ASSERT("Default should be for a MDBox not to be masked!", !box.getIsMasked());
   }
+
+  void test_mask()
+  {
+    MDBox<MDLeanEvent<1>, 1> box;
+    TSM_ASSERT("Default should be unmasked.", !box.getIsMasked());
+    TS_ASSERT_THROWS_NOTHING(box.mask());
+    TSM_ASSERT("Should have been masked.", box.getIsMasked());
+  }
+
+  void test_unmask()
+  {
+    MDBox<MDLeanEvent<1>, 1> box;
+    TSM_ASSERT("Default should be unmasked.", !box.getIsMasked());
+    TS_ASSERT_THROWS_NOTHING(box.unmask());
+    TSM_ASSERT("Should have been masked.", !box.getIsMasked());
+  }
 };
 
 
diff --git a/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h b/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h
index a4d6b0dd58baa615240951cf72d706d526057db7..3a903269df342ed594c04e41981ea6b8ff289485 100644
--- a/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h
+++ b/Code/Mantid/Framework/MDEvents/test/MDEventWorkspaceTest.h
@@ -5,6 +5,7 @@
 #include "MantidAPI/ITableWorkspace.h"
 #include "MantidGeometry/MDGeometry/MDDimensionExtents.h"
 #include "MantidGeometry/MDGeometry/MDHistoDimension.h"
+#include "MantidGeometry/MDGeometry/MDBoxImplicitFunction.h"
 #include "MantidKernel/ProgressText.h"
 #include "MantidKernel/Timer.h"
 #include "MantidAPI/BoxController.h"
@@ -392,6 +393,86 @@ public:
 
   }
 
+  /*
+  Generic masking checking helper method.
+  */
+  void doTestMasking(MDImplicitFunction* function, size_t expectedNumberMasked)
+  {
+    // 10x10x10 eventWorkspace
+    MDEventWorkspace3Lean::sptr ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 1 /*event per box*/);
+
+    ws->setMDMasking(function);
+
+    std::vector<IMDIterator*> its = ws->createIterators(1, NULL);
+    size_t numberMasked = 0;
+    IMDIterator* it = its[0];
+    size_t counter = 0;
+    for(;counter < it->getDataSize(); ++counter)
+    {
+      if(it->getIsMasked())
+      {
+        ++numberMasked;
+      }
+      it->next();
+    }
+    TSM_ASSERT_EQUALS("Didn't perform the masking as expected", expectedNumberMasked, numberMasked);
+  }
+  
+  void test_maskEverything()
+  {
+    std::vector<coord_t> min;
+    std::vector<coord_t> max;
+
+    min.push_back(0);
+    min.push_back(0);
+    min.push_back(0);
+    max.push_back(10);
+    max.push_back(10);
+    max.push_back(10);
+
+    //Create an function that encompases 1/4 of the total bins.
+    MDImplicitFunction* function = new MDBoxImplicitFunction(min, max);
+
+    doTestMasking(function, 1000); //1000 out of 1000 bins masked
+  }
+
+  void test_maskNothing()
+  {
+    std::vector<coord_t> min;
+    std::vector<coord_t> max;
+
+    //Make the box lay over a non-intersecting region of space.
+    min.push_back(-1);
+    min.push_back(-1);
+    min.push_back(-1);
+    max.push_back(-0.01);
+    max.push_back(-0.01);
+    max.push_back(-0.01);
+
+    //Create an function that encompases 1/4 of the total bins.
+    MDImplicitFunction* function = new MDBoxImplicitFunction(min, max);
+
+    doTestMasking(function, 0); //0 out of 1000 bins masked
+  }
+
+  void test_maskHalf()
+  {
+    std::vector<coord_t> min;
+    std::vector<coord_t> max;
+
+    //Make the box that covers half the bins in the workspace. 
+    min.push_back(0);
+    min.push_back(0);
+    min.push_back(0);
+    max.push_back(10);
+    max.push_back(10);
+    max.push_back(4.99);
+
+    //Create an function that encompases 1/4 of the total bins.
+    MDImplicitFunction* function = new MDBoxImplicitFunction(min, max);
+
+    doTestMasking(function, 500); //500 out of 1000 bins masked
+  }
 };
 
 #endif
diff --git a/Code/Mantid/Framework/MDEvents/test/MDGridBoxTest.h b/Code/Mantid/Framework/MDEvents/test/MDGridBoxTest.h
index 2a4fc3a2ee80df02b8348838b080a232e756c1d2..59870653726e129a49a7da59f60f172dca0ebecc 100644
--- a/Code/Mantid/Framework/MDEvents/test/MDGridBoxTest.h
+++ b/Code/Mantid/Framework/MDEvents/test/MDGridBoxTest.h
@@ -49,6 +49,8 @@ private:
   {
   public:
     MOCK_CONST_METHOD0(getIsMasked, bool());
+    MOCK_METHOD0(mask, void());
+    MOCK_METHOD0(unmask, void());
   };
 
 public:
@@ -1408,6 +1410,50 @@ public:
     TS_ASSERT(Mock::VerifyAndClearExpectations(b));
   }
 
+  void test_mask()
+  {
+    std::vector<IMDBox<MDLeanEvent<1>, 1> *> boxes;
+
+    MockMDBox* a = new MockMDBox;
+    MockMDBox* b = new MockMDBox;
+
+    EXPECT_CALL(*a, mask()).Times(1); 
+    EXPECT_CALL(*b, mask()).Times(1); 
+
+    boxes.push_back(a);
+    boxes.push_back(b);
+
+    MDGridBox<MDLeanEvent<1>,1> griddedBox;
+    griddedBox.setChildren(boxes, 0, 2);
+
+    TS_ASSERT_THROWS_NOTHING(griddedBox.mask());//Mask the gridded box
+
+    TS_ASSERT(Mock::VerifyAndClearExpectations(a));
+    TS_ASSERT(Mock::VerifyAndClearExpectations(b));
+  }
+
+  void test_unmask()
+  {
+    std::vector<IMDBox<MDLeanEvent<1>, 1> *> boxes;
+
+    MockMDBox* a = new MockMDBox;
+    MockMDBox* b = new MockMDBox;
+
+    EXPECT_CALL(*a, unmask()).Times(1); 
+    EXPECT_CALL(*b, unmask()).Times(1); 
+
+    boxes.push_back(a);
+    boxes.push_back(b);
+
+    MDGridBox<MDLeanEvent<1>,1> griddedBox;
+    griddedBox.setChildren(boxes, 0, 2);
+
+    TS_ASSERT_THROWS_NOTHING(griddedBox.unmask());//Un-Mask the gridded box
+
+    TS_ASSERT(Mock::VerifyAndClearExpectations(a));
+    TS_ASSERT(Mock::VerifyAndClearExpectations(b));
+  }
+
 private:
   std::string message;
 };
diff --git a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h
index d6e796c4f87140f38e8e2fd7a23e559d1f4f191a..9991a482fa4cf3ba8f0cf9b6360b3a96c3821199 100644
--- a/Code/Mantid/Vates/VatesAPI/test/MockObjects.h
+++ b/Code/Mantid/Vates/VatesAPI/test/MockObjects.h
@@ -10,6 +10,7 @@
 #include "MantidGeometry/MDGeometry/IMDDimension.h"
 #include "MantidGeometry/MDGeometry/MDHistoDimension.h"
 #include "MantidGeometry/MDGeometry/MDTypes.h"
+#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
 #include "MantidMDEvents/MDHistoWorkspace.h"
 #include "MantidVatesAPI/MDLoadingView.h"
 #include "MantidVatesAPI/Clipper.h"
@@ -80,6 +81,7 @@ public:
   MOCK_CONST_METHOD3(getSignalNormalizedAt, double(size_t index1, size_t index2, size_t index3));
   MOCK_CONST_METHOD4(getSignalNormalizedAt, double(size_t index1, size_t index2, size_t index3, size_t index4));
   MOCK_CONST_METHOD0(getNonIntegratedDimensions, Mantid::Geometry::VecIMDDimension_const_sptr());
+  MOCK_METHOD1(setMDMasking, void(Mantid::Geometry::MDImplicitFunction*));
 
   virtual void getLinePlot(const Mantid::Kernel::VMD & , const Mantid::Kernel::VMD & ,
     Mantid::API::MDNormalization , std::vector<Mantid::coord_t> & , std::vector<Mantid::signal_t> & , std::vector<Mantid::signal_t> & ) const