diff --git a/PyNutil/coordinate_extraction.py b/PyNutil/coordinate_extraction.py
index 3b9eddbee705ca09caf83ec8c64c8fcdaae55063..73a326a0441e07dff78c9da4cf5313b9e5cea69b 100644
--- a/PyNutil/coordinate_extraction.py
+++ b/PyNutil/coordinate_extraction.py
@@ -67,7 +67,6 @@ def transform_to_registration(seg_height, seg_width, reg_height, reg_width):
     x_scale = reg_width / seg_width
     return y_scale, x_scale
 
-
 # related to coordinate extraction
 def find_matching_pixels(segmentation, id):
     """This function returns the Y and X coordinates of all the pixels in the segmentation that match the id provided."""
@@ -261,8 +260,8 @@ def segmentation_to_atlas_space(
 
     else:
         segmentation = cv2.imread(segmentation_path)
-    # if pixel_id == "auto":
-    if True:
+    if pixel_id == "auto":
+
         # Remove the background from the segmentation
         segmentation_no_background = segmentation[~np.all(segmentation == 0, axis=2)]
         # pixel_id = np.vstack(
@@ -294,6 +293,7 @@ def segmentation_to_atlas_space(
     y_scale, x_scale = transform_to_registration(
         seg_height, seg_width, reg_height, reg_width
     )
+
     centroids, points = None, None
 
     if method in ["per_object", "all"]:
diff --git a/PyNutil/counting_and_load.py b/PyNutil/counting_and_load.py
index 760e057916fd0a54a5e46de1eea8b859f1dd690a..94c151a70edfb5dc40d62dc87b1f3284f55f0aa3 100644
--- a/PyNutil/counting_and_load.py
+++ b/PyNutil/counting_and_load.py
@@ -166,7 +166,6 @@ def rescale_image(image, rescaleXY):
     w, h = rescaleXY
     return cv2.resize(image, (h, w), interpolation=cv2.INTER_NEAREST)
 
-
 def assign_labels_to_image(image, labelfile):
     w, h = image.shape
     allen_id_image = np.zeros((h, w))  # create an empty image array
@@ -179,8 +178,10 @@ def assign_labels_to_image(image, labelfile):
     return allen_id_image
 
 
-def count_pixels_per_label(image):
+def count_pixels_per_label(image, scale_factor=False):
     unique_ids, counts = np.unique(image, return_counts=True)
+    if scale_factor:
+        counts = counts * scale_factor
     area_per_label = list(zip(unique_ids, counts))
     df_area_per_label = pd.DataFrame(area_per_label, columns=["idx", "region_area"])
     return df_area_per_label
@@ -200,10 +201,15 @@ def flat_to_dataframe(
     print("image shape open", image.shape)
 
     if rescaleXY:
-        image = rescale_image(image, rescaleXY)
+        image_shapeY, image_shapeX = image.shape[0], image.shape[1]
+        image_pixels = image_shapeY * image_shapeX
+        seg_pixels = rescaleXY[0] * rescaleXY[1]
+        scale_factor = seg_pixels / image_pixels
+    else:
+        scale_factor = False
     if (image_vector is None) or (volume is None):
         allen_id_image = assign_labels_to_image(image, labelfile)
     else:
         allen_id_image = image
-    df_area_per_label = count_pixels_per_label(allen_id_image)
+    df_area_per_label = count_pixels_per_label(allen_id_image, scale_factor)
     return df_area_per_label
diff --git a/test/test8_PyNutil_fixed.json b/test/test8_PyNutil_fixed.json
index 8969423c8ec9a40d07910b7cfe82a296ebc0a7b0..4b2d6a18bf250644986f1a5c8d5e1cbccd7ad080 100644
--- a/test/test8_PyNutil_fixed.json
+++ b/test/test8_PyNutil_fixed.json
@@ -1,8 +1,8 @@
 {   "volume_path": "allen2017",
     "label_path": "PyNutil/annotation_volumes/allen2017_colours.csv",
     "segmentation_folder": "PyNutil/test_data/PyTest_seg",
-    "alignment_json": "PyNutil/test_data/PyNutil_testdataset_Nonlin_SY_fixed.json",
+    "alignment_json": "PyNutil/test_data/PyNutil_testdataset_Nonlin_SY_fixed_bigcaudoputamen.json",
     "nonlinear": true,
     "colour": [0, 0, 0],
-    "points_json_path": "PyNutil/outputs/test8_PyNutil.json"
+    "points_json_path": "PyNutil/outputs/test8_PyNutil_use_flat.json"
 }
\ No newline at end of file
diff --git a/testOOP.py b/testOOP.py
index 368f2c4185bff9e97e408613b73ef5d95cf958d5..ab1365d4d7ce2d3a5cf274d8be9b2ffd120833a4 100644
--- a/testOOP.py
+++ b/testOOP.py
@@ -3,11 +3,13 @@ from PyNutil import PyNutil
 pnt = PyNutil(settings_file=r"PyNutil/test/test8_PyNutil_fixed.json")
 ##Use flat can be set to True if you want to use the flat file
 # instead of the visualign json (this is only useful for testing and will be removed)
-pnt.get_coordinates(object_cutoff=0, use_flat=False)
+pnt.get_coordinates(object_cutoff=0, use_flat=True)
 
 pnt.quantify_coordinates()
 
-pnt.save_analysis("PyNutil/outputs/test8_PyNutil")
+pnt.save_analysis("PyNutil/outputs/test8_PyNutil_bigcaudoputamen_newatlasmaps")
 
 # remove name, r, g, b, from pixel_
 # add to region_areas df
+
+
diff --git a/test_data/PyNutil_testdataset_Nonlin_SY_fixed_bigcaudoputamen.json b/test_data/PyNutil_testdataset_Nonlin_SY_fixed_bigcaudoputamen.json
new file mode 100644
index 0000000000000000000000000000000000000000..afcf51c0fdf39a19611b6526fd0bb2c7e74dadfd
--- /dev/null
+++ b/test_data/PyNutil_testdataset_Nonlin_SY_fixed_bigcaudoputamen.json
@@ -0,0 +1,6 @@
+{"name":"PyNutil_testdataset","target":"ABA_Mouse_CCFv3_2017_25um.cutlas","target-resolution":[456.0, 528.0, 320.0],"slices":[
+{"filename":"test_s001.png","nr":1,"width":1500,"height":1000,"anchoring":[-5.145275115966797, 361.8014440433213, 331.1490739071843, 456.0, 0.0, 0.0, 0.0, 0.0, -320.0],"markers":[[675.1336898395723, 571.1229946524063, 675.1336898395722, 571.1229946524064], [862.2994652406418, 587.1657754010693, 862.2994652406417, 587.1657754010695], [462.29946524064167, 485.5614973262032, 232.3529411764706, 320.8556149732621], [462.2618138532621, 686.9522625381479, 205.6149732620321, 932.6203208556149], [1065.5080213903743, 479.1443850267384, 1305.0802139037437, 259.89304812834223], [874.0684663788843, 528.257146231987, 832.3529411764705, 360.4278074866309], [1076.6584104086885, 691.7768773152915, 1329.6791443850263, 922.9946524064171]]}, 
+{"filename":"test_s002.png","nr":2,"width":1500,"height":1000,"anchoring":[-3.8589563369750977, 318.7157039711191, 340.24552914037605, 456.0, 0.0, 0.0, 0.0, 0.0, -320.0],"markers":[[636.8098159509204, 603.4958601655935, 672.6993865030674, 593.3762649494021], [902.9868982011025, 615.5567336628567, 843.8650306748466, 610.8555657773691], [561.2609204260139, 750.3661510917975, 558.5889570552147, 775.5289788408462]]}, 
+{"filename":"test_s003.png","nr":3,"width":1500,"height":1000,"anchoring":[-2.8942172527313232, 275.6299638989171, 350.0189942541106, 456.0, 0.0, 0.0, 0.0, 0.0, -320.0],"markers":[[761.0429447852762, 629.2548298068077, 761.0429447852761, 629.2548298068077], [204.29447852760745, 613.6154553817848, 365.3374233128834, 612.695492180313], [482.6376861494953, 714.9876920193675, 623.0061349693251, 747.0101195952162], [434.00208292806684, 606.7676930120547, 578.8343558282207, 601.6559337626494], [959.8159509202455, 636.6145354185834, 980.0613496932516, 628.3348666053357], [957.8161415293836, 523.3987679117937, 953.3742331288344, 547.3781048758049]]}, 
+{"filename":"test_s004.png","nr":4,"width":1500,"height":1000,"anchoring":[-3.0282087922096252, 232.54422382671487, 364.1366059225139, 456.0, 0.0, 0.0, 0.0, 0.0, -320.0],"markers":[[522.6993865030674, 712.9714811407543, 530.6338374725239, 715.7313707451705], [630.6438500513034, 523.1833943062713, 550.3067484662577, 519.7792088316469], [916.4047791164191, 534.1886045162021, 962.5766871165645, 523.4590616375344], [950.8076359295408, 705.46368100121, 949.6932515337423, 701.0119595216191], [1096.1208774051677, 649.3153717520049, 1099.6932515337426, 656.8537258509658], [1030.2378410339393, 594.2011916220456, 1065.644171779141, 604.4158233670653]]}, 
+{"filename":"test_s005.png","nr":5,"width":1500,"height":1000,"anchoring":[-0.6163610816001892, 189.45848375451277, 374.2485759765199, 456.0, 0.0, 0.0, 0.0, 0.0, -320.0],"markers":[[6.441717791411037, 588.7764489420423, 186.80981595092024, 425.0229990800368], [766.3836793259812, 987.3315412211099, 834.6625766871166, 946.6421343146276], [447.4522362685242, 740.6361518118404, 565.9509202453987, 643.0542778288868], [392.2943778764543, 594.4761834437141, 542.9447852760735, 478.3808647654094], [1117.436664514756, 564.5422630203066, 788.6503067484659, 422.2631094756209], [1045.7025247722827, 975.3508578153971, 893.5582822085888, 873.045078196872]]}]}
\ No newline at end of file
diff --git a/test_data/PyTest_seg/flat_files/report.tsv b/test_data/PyTest_seg/flat_files/report.tsv
new file mode 100644
index 0000000000000000000000000000000000000000..da16b9d4af838514abd73333158c19b733bf7c5b
--- /dev/null
+++ b/test_data/PyTest_seg/flat_files/report.tsv
@@ -0,0 +1,6 @@
+snr	name	segmented	changed	stable%
+1	test_s001.png	108266	95135	12%
+2	test_s002.png	83702	34124	59%
+3	test_s003.png	93593	67152	28%
+4	test_s004.png	97022	44431	54%
+5	test_s005.png	92810	90411	2%
diff --git a/test_data/PyTest_seg/flat_files/test_s001_nl.flat b/test_data/PyTest_seg/flat_files/test_s001_nl.flat
index e82b1e4b1019ffa83475844787dc639b2bbaa83f..4fff3fa78c5a9a3c5e5638e3238e0756c5de52c9 100644
Binary files a/test_data/PyTest_seg/flat_files/test_s001_nl.flat and b/test_data/PyTest_seg/flat_files/test_s001_nl.flat differ
diff --git a/test_data/PyTest_seg/flat_files/test_s001_nl.png b/test_data/PyTest_seg/flat_files/test_s001_nl.png
index b29e104e0c9760e86cddf9236e4ad4f0746d21dd..f71fd9f7da67b9eba543f4fbef82cbe8755205a7 100644
Binary files a/test_data/PyTest_seg/flat_files/test_s001_nl.png and b/test_data/PyTest_seg/flat_files/test_s001_nl.png differ
diff --git a/test_data/PyTest_seg/flat_files/test_s001_nl_rbw.png b/test_data/PyTest_seg/flat_files/test_s001_nl_rbw.png
index 742cf759f7cfe7cda135d46ce0bbd6f8669c3369..347c2254e99c5c16ee488fbf02e64ade918736f3 100644
Binary files a/test_data/PyTest_seg/flat_files/test_s001_nl_rbw.png and b/test_data/PyTest_seg/flat_files/test_s001_nl_rbw.png differ
diff --git a/test_data/PyTest_seg/flat_files/test_s002_nl_rbw.png b/test_data/PyTest_seg/flat_files/test_s002_nl_rbw.png
index 5455ca268be872bc4ab9233344a3e5dd0c95b0b9..964c06e5085f9e4046fa7ccfef242bc95f12304a 100644
Binary files a/test_data/PyTest_seg/flat_files/test_s002_nl_rbw.png and b/test_data/PyTest_seg/flat_files/test_s002_nl_rbw.png differ
diff --git a/test_data/PyTest_seg/flat_files/test_s003_nl_rbw.png b/test_data/PyTest_seg/flat_files/test_s003_nl_rbw.png
index 26e69527bf65ca3f064ef6989ae08848ed17a104..5a381408a85276a0eda44fca6cb611195ad1c064 100644
Binary files a/test_data/PyTest_seg/flat_files/test_s003_nl_rbw.png and b/test_data/PyTest_seg/flat_files/test_s003_nl_rbw.png differ
diff --git a/test_data/PyTest_seg/flat_files/test_s004_nl_rbw.png b/test_data/PyTest_seg/flat_files/test_s004_nl_rbw.png
index 23472c94287db4506c2892763e51584e2bd06db7..e9cc624737f9515401aef4fddce61409e70e6142 100644
Binary files a/test_data/PyTest_seg/flat_files/test_s004_nl_rbw.png and b/test_data/PyTest_seg/flat_files/test_s004_nl_rbw.png differ
diff --git a/test_data/PyTest_seg/flat_files/test_s005_nl_rbw.png b/test_data/PyTest_seg/flat_files/test_s005_nl_rbw.png
index a2755bccccb8859a79166a0060527e28964695e2..89df0fd1db2105afaf67019d7738e4f40542f998 100644
Binary files a/test_data/PyTest_seg/flat_files/test_s005_nl_rbw.png and b/test_data/PyTest_seg/flat_files/test_s005_nl_rbw.png differ