W. Eric L. Grimson

156 papers A* 34A 14B 2Journal 52Unranked 52
YearRankTypeTitle / Venue / Authors
2016 J jnl
Medical Image Anal.
Tina Kapur, Steve Pieper, Andriy Fedorov, Jean-Christophe Fillion-Robin, Michael Halle, Lauren O'Donnell, Andras Lasso, Tamas Ungi, Csaba Pinter, Julien Finet, Sonia Pujol, Jagadeesan Jayender, Junichi Tokuda, Isaiah Norton, Raúl San José Estépar, David T. Gering, Hugo J. W. L. Aerts, Marianna Jakab, Nobuhiko Hata, Luiz Ibáñez, Daniel J. Blezek, Jim Miller, Stephen R. Aylward, W. Eric L. Grimson, Gabor Fichtinger, William M. Wells III, William E. Lorensen, William J. Schroeder, Ron Kikinis
2012 J jnl
IEEE Trans. Image Process.
Jiann-Jone Chen, Chun-Rong Su, W. Eric L. Grimson, Jun-Lin Liu, De-Hui Shiue
2011 J jnl
NeuroImage
Xiaogang Wang, W. Eric L. Grimson, Carl-Fredrik Westin
2011 J jnl
Int. J. Comput. Vis.
Xiaogang Wang, Keng Teck Ma, Gee Wah Ng, W. Eric L. Grimson
2010 J jnl
NeuroImage
Anna Custo, David A. Boas, Daisuke Tsuzuki, Ippeita Dan, Rickson Mesquita, Bruce Fischl, W. Eric L. Grimson, William M. Wells III
2010 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
Xiaogang Wang, Kinh Tieu, W. Eric L. Grimson
2009 J jnl
Int. J. Comput. Vis.
Ulas Ziyan, Mert R. Sabuncu, W. Eric L. Grimson, Carl-Fredrik Westin
2009 A* conf
CVPR
Dahua Lin, W. Eric L. Grimson, John W. Fisher III
2009 conf
IPMI
Xiaogang Wang, W. Eric L. Grimson, Carl-Fredrik Westin
2009 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
Xiaogang Wang, Xiaoxu Ma, W. Eric L. Grimson
2008 conf
ISBI
Mahnaz Maddah, Lilla Zöllei, W. Eric L. Grimson, Carl-Fredrik Westin, William M. Wells III
2008 J jnl
Medical Image Anal.
Mahnaz Maddah, W. Eric L. Grimson, Simon K. Warfield, William M. Wells III
2008 A conf
WACV
Gerald Dalley, Joshua Migdal, W. Eric L. Grimson
2008 A* conf
CVPR
Xiaogang Wang, Kinh Tieu, W. Eric L. Grimson
2008 conf
MICCAI (1)
Mahnaz Maddah, Marek Kubicki, William M. Wells III, Carl-Fredrik Westin, Martha Elizabeth Shenton, W. Eric L. Grimson
2008 A* conf
CVPR
Xiaoxu Ma, W. Eric L. Grimson
2008 conf
CVPR Workshops
Mahnaz Maddah, Lilla Zöllei, W. Eric L. Grimson, William M. Wells III
2008 A* conf
CVPR
Xiaogang Wang, Keng Teck Ma, Gee Wah Ng, W. Eric L. Grimson
2007 J jnl
IEEE Trans. Medical Imaging
Kilian M. Pohl, Sylvain Bouix, Motoaki Nakamura, Torsten Rohlfing, Robert W. McCarley, Ron Kikinis, W. Eric L. Grimson, Martha Elizabeth Shenton, William M. Wells III
2007 A* conf
ICCV
Ulas Ziyan, Mert R. Sabuncu, W. Eric L. Grimson, Carl-Fredrik Westin
2007 conf
IPMI
Mahnaz Maddah, William M. Wells III, Simon K. Warfield, Carl-Fredrik Westin, W. Eric L. Grimson
2007 J jnl
Image Vis. Comput.
Tomás Izo, W. Eric L. Grimson
2007 conf
ICIP (4)
Tomás Izo, W. Eric L. Grimson
2007 J jnl
Medical Image Anal.
Kilian M. Pohl, John W. Fisher III, Sylvain Bouix, Martha Elizabeth Shenton, Robert W. McCarley, W. Eric L. Grimson, Ron Kikinis, William M. Wells III
2006 J jnl
NeuroImage
Kilian M. Pohl, John W. Fisher III, W. Eric L. Grimson, Ron Kikinis, William M. Wells III
2006 conf
MICCAI (2)
Kilian M. Pohl, John W. Fisher III, Martha Elizabeth Shenton, Robert W. McCarley, W. Eric L. Grimson, Ron Kikinis, William M. Wells III
2006 conf
ISBI
Mahnaz Maddah, W. Eric L. Grimson, Simon K. Warfield
2005 conf
IPMI
Florent Ségonne, W. Eric L. Grimson, Bruce Fischl
2005 A conf
MICCAI
Kilian M. Pohl, John W. Fisher III, James J. Levitt, Martha Elizabeth Shenton, Ron Kikinis, W. Eric L. Grimson, William M. Wells III
2005 conf
CVBIA
Florent Ségonne, Jean-Philippe Pons, W. Eric L. Grimson, Bruce Fischl
2005 conf
CVBIA
W. Eric L. Grimson, Polina Golland
2005 A conf
MICCAI
Mahnaz Maddah, Andrea J. U. Mewes, Steven Haker, W. Eric L. Grimson, Simon K. Warfield
2005 conf
WACV/MOTION
Joshua Migdal, W. Eric L. Grimson
2005 J jnl
Medical Image Anal.
Polina Golland, W. Eric L. Grimson, Martha Elizabeth Shenton, Ron Kikinis
2005 A* conf
ICCV
Xiaoxu Ma, W. Eric L. Grimson
2005 conf
CVBIA
Lilla Zöllei, Erik G. Learned-Miller, W. Eric L. Grimson, William M. Wells III
2005 A* conf
ICCV
Kinh Tieu, Gerald Dalley, W. Eric L. Grimson
2005 conf
CVBIA
Kilian M. Pohl, John W. Fisher III, Ron Kikinis, W. Eric L. Grimson, William M. Wells III
2004 conf
MICCAI (2)
Corey Kemper, Ion-Florin Talos, Alexandra J. Golby, Peter M. Black, Ron Kikinis, W. Eric L. Grimson, Simon K. Warfield
2004 conf
ISBI
Kilian M. Pohl, W. Eric L. Grimson, Sylvain Bouix, Ron Kikinis
2004 conf
New Directions in Question Answering
Boris Katz, Jimmy Lin, Chris Stauffer, W. Eric L. Grimson
2004 conf
MICCAI (1)
Kilian M. Pohl, Simon K. Warfield, Ron Kikinis, W. Eric L. Grimson, William M. Wells III
2004 conf
CVPR (2)
Biswajit Bose, W. Eric L. Grimson
2004 conf
MICCAI (1)
Lauren O'Donnell, W. Eric L. Grimson, Carl-Fredrik Westin
2004 J jnl
J. Inf. Sci. Eng.
Jun-Wei Hsieh, Cheng-Chin Chiang, Yea-Shuan Huang, W. Eric L. Grimson
2004 conf
CVPR Workshops
Tomás Izo, W. Eric L. Grimson
2003 J jnl
IEEE Trans. Medical Imaging
Andy Tsai, Anthony J. Yezzi, William M. Wells III, Clare M. Tempany, Dewey Tucker, Ayres C. Fan, W. Eric L. Grimson, Alan S. Willsky
2003 conf
New Directions in Question Answering
Boris Katz, Jimmy Lin, Chris Stauffer, W. Eric L. Grimson
2003 conf
IPMI
Andy Tsai, William M. Wells III, Clare M. Tempany, W. Eric L. Grimson, Alan S. Willsky
2003 conf
MICCAI (1)
Lilla Zöllei, Lawrence P. Panych, W. Eric L. Grimson, William M. Wells III
2003 conf
WBIR
Salil Soman, Albert C. S. Chung, W. Eric L. Grimson, William M. Wells III
2003 J jnl
IEEE Trans. Image Process.
Jun-Wei Hsieh, W. Eric L. Grimson
2003 conf
MICCAI (2)
Florent Ségonne, W. Eric L. Grimson, Bruce Fischl
2002 conf
MICCAI (1)
Polina Golland, Bruce Fischl, Mona Spiridon, Nancy Kanwisher, Randy L. Buckner, Martha Elizabeth Shenton, Ron Kikinis, Anders M. Dale, W. Eric L. Grimson
2002 conf
FGR
L. Lee, W. Eric L. Grimson
2002 conf
Biometric Authentication
L. Lee, W. Eric L. Grimson
2002 conf
MICCAI (1)
Kilian M. Pohl, William M. Wells III, Alexandre Guimond, Kiyoto Kasai, Martha Elizabeth Shenton, Ron Kikinis, W. Eric L. Grimson, Simon K. Warfield
2002 conf
MICCAI (2)
Delphine Nain, Steven Haker, W. Eric L. Grimson, Eric R. Cosman Jr., William M. Wells III, Hoon Ji, Ron Kikinis, Carl-Fredrik Westin
2002 conf
MICCAI (2)
Albert C. S. Chung, William M. Wells III, Alexander Norbash, W. Eric L. Grimson
2002 conf
MICCAI (1)
Samson J. Timoner, Polina Golland, Ron Kikinis, Martha Elizabeth Shenton, W. Eric L. Grimson, William M. Wells III
2002 J jnl
Pattern Recognit.
Yea-Shuan Huang, Cheng-Chin Chiang, Jun-Wei Shieh, W. Eric L. Grimson
2002 conf
MICCAI (1)
David T. Gering, W. Eric L. Grimson, Ron Kikinis
2002 conf
ICME (1)
Jun-Wei Hsieh, W. Eric L. Grimson
2001 conf
CVPR (2)
Lilla Zöllei, W. Eric L. Grimson, Alexander Norbash, William M. Wells III
2001 J jnl
Medical Image Anal.
Liana M. Lorigo, Olivier D. Faugeras, W. Eric L. Grimson, Renaud Keriven, Ron Kikinis, Arya Nabavi, Carl-Fredrik Westin
2001 conf
IEEE Pacific Rim Conference on Multimedia
Huizhen Yu, W. Eric L. Grimson
2001 conf
IPMI
Polina Golland, W. Eric L. Grimson, Martha Elizabeth Shenton, Ron Kikinis
2001 A conf
MICCAI
Samson J. Timoner, W. Eric L. Grimson, Ron Kikinis, William M. Wells III
2001 conf
CVPR (1)
Andy Tsai, Anthony J. Yezzi, William M. Wells III, Clare M. Tempany, Dewey Tucker, Ayres C. Fan, W. Eric L. Grimson, Alan S. Willsky
2001 A conf
MICCAI
Lauren O'Donnell, Carl-Fredrik Westin, W. Eric L. Grimson, Juan Ruiz-Alzola, Martha Elizabeth Shenton, Ron Kikinis
2001 conf
CVPR (1)
Chris Stauffer, W. Eric L. Grimson
2000 A* conf
CVPR
Liana M. Lorigo, W. Eric L. Grimson, Olivier D. Faugeras, Renaud Keriven, Ron Kikinis, Arya Nabavi, Carl-Fredrik Westin
2000 A conf
BMVC
W. Eric L. Grimson, Michael E. Leventon, Olivier D. Faugeras
2000 B conf
ICPR
Yea-Shuan Huang, Cheng-Chin Chiang, Jun-Wei Shieh, W. Eric L. Grimson
2000 A* conf
CVPR
Polina Golland, W. Eric L. Grimson
2000 J jnl
Medical Image Anal.
W. Eric L. Grimson, Ron Kikinis
2000 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
Chris Stauffer, W. Eric L. Grimson
2000 J jnl
Int. J. Comput. Vis.
Aparna Lakshmi Ratan, W. Eric L. Grimson, William M. Wells III
2000 B conf
ICIP
Jun-Wei Hsieh, W. Eric L. Grimson, Cheng-Chin Chiang, Yea-Shuan Huang
2000 A conf
MICCAI
Carl-Fredrik Westin, Liana M. Lorigo, Olivier D. Faugeras, W. Eric L. Grimson, Steven Dawson, Alexander Norbash, Ron Kikinis
2000 A conf
MICCAI
Polina Golland, W. Eric L. Grimson, Martha Elizabeth Shenton, Ron Kikinis
2000 A* conf
CVPR
Michael E. Leventon, W. Eric L. Grimson, Olivier D. Faugeras
1999 A* conf
CVPR
Aparna Lakshmi Ratan, Oded Maron, W. Eric L. Grimson, Tomás Lozano-Pérez
1999 A* conf
CVPR
Chris Stauffer, W. Eric L. Grimson
1999 A conf
MICCAI
David T. Gering, Arya Nabavi, Ron Kikinis, W. Eric L. Grimson, Nobuhiko Hata, Peter Everett, Ferenc A. Jolesz, William M. Wells III
1999 conf
IPMI
Liana M. Lorigo, Olivier D. Faugeras, W. Eric L. Grimson, Renaud Keriven, Ron Kikinis, Carl-Fredrik Westin
1999 conf
IPMI
Polina Golland, W. Eric L. Grimson, Ron Kikinis
1998 J jnl
Comput. Vis. Image Underst.
Kenji Nagao, W. Eric L. Grimson
1998 A conf
MICCAI
W. Eric L. Grimson, Michael E. Leventon, Gil J. Ettinger, Alexandra Chabrerie, Fatma Ozlen, Shin Nakajima, Hideki Atsumi, Ron Kikinis, Peter M. Black
1998 A conf
MICCAI
Tina Kapur, W. Eric L. Grimson, Ron Kikinis, William M. Wells III
1998 J jnl
Medical Image Anal.
Gil J. Ettinger, Michael E. Leventon, W. Eric L. Grimson, Ron Kikinis, Laverne Gugino, Wayne Cote, Larry Sprung, Linda Aglio, Martha Elizabeth Shenton, Geoff Potts, Victor L. Hernandez, Eben Alexander
1998 conf
ACCV (1)
W. Eric L. Grimson
1998 A conf
MICCAI
Michael E. Leventon, W. Eric L. Grimson
1998 A* conf
CVPR
Aparna Lakshmi Ratan, W. Eric L. Grimson, William M. Wells III
1998 A conf
MICCAI
Liana M. Lorigo, Olivier D. Faugeras, W. Eric L. Grimson, Renaud Keriven, Ron Kikinis
1998 A conf
MICCAI
Alexandra Chabrerie, Fatma Ozlen, Shin Nakajima, Michael E. Leventon, Hideki Atsumi, W. Eric L. Grimson, Erwin Keeve, Sandra Helmers, James Riviello Jr., Gregory Holmes II, Frank Duffy, Ferenc A. Jolesz, Ron Kikinis, Peter M. Black
1998 A* conf
CVPR
W. Eric L. Grimson, Chris Stauffer, R. Romano, L. Lee
1998 J jnl
Comput. Vis. Image Underst.
Kenji Nagao, W. Eric L. Grimson
1997 ed.
CVRMed-MRCAS
Jocelyne Troccaz, W. Eric L. Grimson, Ralf Mösges
1997 conf
CVRMed
Gil J. Ettinger, Michael E. Leventon, W. Eric L. Grimson, Ron Kikinis, V. Gugino, Wayne Cote, Larry Sprung, Linda Aglio, Martha Elizabeth Shenton, Geoff Potts, Eben Alexander
1997 J jnl
Int. J. Comput. Vis.
W. Eric L. Grimson
1997 conf
CVRMed
Sarah F. Gibson, Joseph Samosky, Andrew B. Mor, Christina Fyock, W. Eric L. Grimson, Takeo Kanade, Ron Kikinis, Hugh C. Lauer, Neil McKenzie, Shin Nakajima, TakaHide Ohkami, Randy Osborne, Akira Sawada
1997 J jnl
Int. J. Pattern Recognit. Artif. Intell.
W. Eric L. Grimson, Tina Kapur, Gil J. Ettinger, Michael E. Leventon, William M. Wells III, Ron Kikinis
1997 A* conf
CVPR
T. D. Alter, W. Eric L. Grimson
1996 J jnl
IEEE Trans. Medical Imaging
William M. Wells III, W. Eric L. Grimson, Ron Kikinis, Ferenc A. Jolesz
1996 J jnl
IEEE Trans. Medical Imaging
W. Eric L. Grimson, Gil J. Ettinger, Steve J. White, Tomás Lozano-Pérez, William M. Wells III, Ron Kikinis
1996 J jnl
Medical Image Anal.
Tina Kapur, W. Eric L. Grimson, William M. Wells III, Ron Kikinis
1995 conf
CVRMed
William M. Wells III, W. Eric L. Grimson, Ron Kikinis, Ferenc A. Jolesz
1995 conf
CVRMed
W. Eric L. Grimson, Gil J. Ettinger, Steve J. White, P. Langham Gleason, Tomás Lozano-Pérez, William M. Wells III, Ron Kikinis
1995 J jnl
IEEE Expert
W. Eric L. Grimson
1995 conf
CVRMed
Tina Kapur, W. Eric L. Grimson, Ron Kikinis
1994 J jnl
Int. J. Comput. Vis.
W. Eric L. Grimson, Daniel P. Huttenlocher, David W. Jacobs
1994 A* conf
CVPR
W. Eric L. Grimson, Tomás Lozano-Pérez, Steve J. White, William M. Wells III, Ron Kikinis, Gil J. Ettinger
1994 J jnl
Commun. ACM
W. Eric L. Grimson, Joseph L. Mundy
1994 conf
VBC
Ron Kikinis, P. Langham Gleason, William E. Lorensen, William M. Wells III, W. Eric L. Grimson, Tomás Lozano-Pérez, Gil J. Ettinger, Steven F. White, Ferenc A. Jolesz
1994 conf
ICPR (1)
Kenji Nagao, W. Eric L. Grimson
1994 conf
VBC
William M. Wells III, W. Eric L. Grimson, Ron Kikinis, Ferenc A. Jolesz
1993 A* conf
CVPR
W. Eric L. Grimson, Tomás Lozano-Pérez, N. Noble, Steve J. White
1993 A* conf
ICCV
Tao Daniel Alter, W. Eric L. Grimson
1993 A* conf
CVPR
Karen Beth Sarachik, W. Eric L. Grimson
1992 A* conf
ECCV
W. Eric L. Grimson, Daniel P. Huttenlocher, David W. Jacobs
1992 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson, Daniel P. Huttenlocher
1992 A* conf
CVPR
W. Eric L. Grimson, Daniel P. Huttenlocher, Tao Daniel Alter
1992 J jnl
Int. J. Comput. Vis.
W. Eric L. Grimson
1991 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson, Daniel P. Huttenlocher
1991 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson, Daniel P. Huttenlocher
1991 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson
1990 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson, Daniel P. Huttenlocher
1990 A* conf
ECCV
W. Eric L. Grimson, Daniel P. Huttenlocher
1990 A* conf
ICCV
W. Eric L. Grimson, Daniel P. Huttenlocher
1990 ch.
Autonomous Robot Vehicles
W. Eric L. Grimson
1990 A* conf
ECCV
W. Eric L. Grimson
1990 J jnl
Artif. Intell.
W. Eric L. Grimson
1990 A* conf
ICCV
W. Eric L. Grimson
1989 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson
1989 J jnl
Int. J. Comput. Vis.
W. Eric L. Grimson
1988 A* conf
ICCV
W. Eric L. Grimson, Daniel P. Huttenlocher
1988 A* conf
ICRA
W. Eric L. Grimson
1988 A* conf
ICCV
W. Eric L. Grimson
1987 A* conf
ICRA
Tomás Lozano-Pérez, W. Eric L. Grimson, Steve J. White
1987 A* conf
ICRA
Tomás Lozano-Pérez, Joseph L. Jones, Emmanuel Mazer, Patrick A. O'Donnell, W. Eric L. Grimson, Pierre Tournassoud, Alain Lanusse
1987 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson, Tomás Lozano-Pérez
1986 A* conf
ICRA
W. Eric L. Grimson
1986 conf
FJCC
Tomás Lozano-Pérez, W. Eric L. Grimson
1986 J jnl
IEEE J. Robotics Autom.
W. Eric L. Grimson
1986 J jnl
J. ACM
W. Eric L. Grimson
1985 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson, Ellen C. Hildreth
1985 J jnl
IEEE Trans. Pattern Anal. Mach. Intell.
W. Eric L. Grimson
1985 J jnl
Comput. Vis. Graph. Image Process.
W. Eric L. Grimson, Theodosios Pavlidis
1985 A* conf
ICRA
W. Eric L. Grimson, Tomás Lozano-Pérez
1984 J jnl
Comput. Vis. Graph. Image Process.
W. Eric L. Grimson
1984 A* conf
ICRA
W. Eric L. Grimson, Tomás Lozano-Pérez
1983 J jnl
Comput. Vis. Graph. Image Process.
W. Eric L. Grimson
1983 J jnl
Comput. Vis. Graph. Image Process.
W. Eric L. Grimson
1982 J jnl
Comput. Graph. Image Process.
W. Eric L. Grimson
1980 A* conf
AAAI
Mike Brady, W. Eric L. Grimson, D. J. Langridge
tests/unit/test_smali_normalization.py
← Index tests/unit/test_smali_normalization.py python
"""Unit tests for smali semantic normalization.

Tests the three normalization levels (category, opcode, opcode_api),
opcode categorization, ACFG feature index mapping, and integration
with MinHash computation.
"""
import pytest

pytestmark = [pytest.mark.unit, pytest.mark.apk, pytest.mark.decompile]


class TestCategorizeOpcode:
    """Tests for opcode -> semantic category mapping."""

    def test_arithmetic(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("add-int") == "ALU"
        assert categorize_opcode("mul-long/2addr") == "ALU"
        assert categorize_opcode("neg-int") == "ALU"

    def test_data_movement(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("move-result") == "MOV"
        assert categorize_opcode("const/4") == "CONST"
        assert categorize_opcode("const-string") == "CONST"

    def test_memory_access(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("iget-object") == "LOAD"
        assert categorize_opcode("sput-wide") == "STORE"
        assert categorize_opcode("aget-byte") == "LOAD"

    def test_invocation(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("invoke-virtual") == "CALL"
        assert categorize_opcode("invoke-static") == "CALL"
        assert categorize_opcode("invoke-direct") == "CALL"

    def test_control_flow(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("if-eqz") == "BRANCH"
        assert categorize_opcode("goto") == "JMP"
        assert categorize_opcode("goto/16") == "JMP"
        assert categorize_opcode("return-void") == "RET"

    def test_comparison(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("cmp-long") == "CMP"
        assert categorize_opcode("cmpl-float") == "CMP"
        assert categorize_opcode("cmpg-double") == "CMP"

    def test_conversion(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("int-to-long") == "CONV"
        assert categorize_opcode("float-to-int") == "CONV"

    def test_object_type(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("new-instance") == "ALLOC"
        assert categorize_opcode("check-cast") == "TYPE"
        assert categorize_opcode("instance-of") == "TYPE"

    def test_exception_sync(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("throw") == "EXC"
        assert categorize_opcode("monitor-enter") == "SYNC"

    def test_unknown(self):
        from redb.extractors.decompiler.apk.smali_normalization import categorize_opcode
        assert categorize_opcode("nop") == "OTHER"


class TestNormalizeInstruction:
    """Tests for single instruction normalization at various levels."""

    def test_category_level(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        assert normalize_instruction("add-int v0, v1, v2", "category") == "ALU"
        assert normalize_instruction("invoke-virtual {p0}, Lcom/Foo;->bar()V", "category") == "CALL"
        assert normalize_instruction("return-void", "category") == "RET"

    def test_opcode_level_strips_width(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        # Width variants collapse to same base
        assert normalize_instruction("add-int v0, v1, v2", "opcode") == "add"
        assert normalize_instruction("add-long v0, v2, v4", "opcode") == "add"
        assert normalize_instruction("add-float v0, v1, v2", "opcode") == "add"
        # Addressing modes collapse too
        assert normalize_instruction("add-int/2addr v0, v1", "opcode") == "add"

    def test_opcode_api_invoke(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        result = normalize_instruction(
            "invoke-virtual {p0, v0}, Lcom/example/Foo;->bar(I)V"
        )
        assert result == "CALL Lcom/example/Foo;->bar(I)V"

    def test_opcode_api_invoke_no_ref(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        # If somehow no method ref is found, fallback to CALL
        assert normalize_instruction("invoke-virtual {v0}") == "CALL"

    def test_opcode_api_field_load(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        result = normalize_instruction(
            "iget-object v0, p0, Lcom/Foo;->mField:Ljava/lang/String;"
        )
        assert result == "LOAD Lcom/Foo;->mField:Ljava/lang/String;"

    def test_opcode_api_field_store(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        result = normalize_instruction(
            "iput-object v0, p0, Lcom/Foo;->mField:Ljava/lang/String;"
        )
        assert result == "STORE Lcom/Foo;->mField:Ljava/lang/String;"

    def test_opcode_api_androguard_field_format(self):
        """androguard uses space instead of colon in field references."""
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        result = normalize_instruction(
            "iget-object v0, p0, Lcom/Foo;->mField Ljava/lang/String;"
        )
        assert result.startswith("LOAD")
        assert "Lcom/Foo;->mField" in result

    def test_opcode_api_new_instance(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        result = normalize_instruction(
            "new-instance v0, Lcom/example/MyClass;"
        )
        assert result == "ALLOC Lcom/example/MyClass;"

    def test_opcode_api_const_string(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        result = normalize_instruction(
            'const-string v0, "hello world"'
        )
        assert result == 'CONST_STR "hello world"'

    def test_opcode_api_const_string_jumbo(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        result = normalize_instruction(
            'const-string/jumbo v0, "large string"'
        )
        assert result == 'CONST_STR "large string"'

    def test_opcode_api_fallback_to_category(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        # Non-special instructions fall back to category
        assert normalize_instruction("add-int v0, v1, v2") == "ALU"
        assert normalize_instruction("return-void") == "RET"
        assert normalize_instruction("nop") == "OTHER"

    def test_empty_input(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_instruction
        assert normalize_instruction("") == ""
        assert normalize_instruction("   ") == ""


class TestNormalizeMethodBody:
    """Tests for full method body normalization."""

    def test_filters_directives_labels_comments(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_method_body
        body = """\
.locals 2
# comment
:label_0
add-int v0, v1, v2
.line 42
invoke-virtual {p0}, Lcom/Foo;->bar()V
return-void
"""
        result = normalize_method_body(body, "category")
        assert result == ["ALU", "CALL", "RET"]

    def test_opcode_api_preserves_api_refs(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_method_body
        body = """\
const/4 v0, 0x0
invoke-virtual {p0, v0}, Lcom/Foo;->setX(I)V
iget-object v1, p0, Lcom/Foo;->name:Ljava/lang/String;
return-void
"""
        result = normalize_method_body(body, "opcode_api")
        assert result[0] == "CONST"
        assert result[1] == "CALL Lcom/Foo;->setX(I)V"
        assert result[2] == "LOAD Lcom/Foo;->name:Ljava/lang/String;"
        assert result[3] == "RET"

    def test_empty_body(self):
        from redb.extractors.decompiler.apk.smali_normalization import normalize_method_body
        assert normalize_method_body("") == []
        assert normalize_method_body("\n\n") == []


class TestNormalizationWithMinHash:
    """Integration tests: normalization + MinHash computation."""

    def test_minhash_returns_signature(self):
        from redb.extractors.decompiler.apk.method_extractor import compute_minhash
        body = """\
const/4 v0, 0x0
invoke-virtual {p0, v0}, Lcom/Foo;->bar(I)V
iget-object v1, p0, Lcom/Foo;->name:Ljava/lang/String;
add-int v2, v0, v1
return-void
"""
        sig = compute_minhash(body)
        assert sig is not None
        assert len(sig) == 64
        assert all(0 <= v < 256 for v in sig)

    def test_minhash_register_invariance(self):
        """Same operations with different registers should produce identical signatures."""
        from redb.extractors.decompiler.apk.method_extractor import compute_minhash
        body_a = """\
const/4 v0, 0x0
invoke-virtual {p0, v0}, Lcom/Foo;->bar(I)V
iget-object v1, p0, Lcom/Foo;->name:Ljava/lang/String;
add-int v2, v0, v1
return-void
"""
        body_b = """\
const/4 v3, 0x0
invoke-virtual {p1, v3}, Lcom/Foo;->bar(I)V
iget-object v4, p1, Lcom/Foo;->name:Ljava/lang/String;
add-int v5, v3, v4
return-void
"""
        sig_a = compute_minhash(body_a)
        sig_b = compute_minhash(body_b)
        assert sig_a == sig_b

    def test_minhash_width_invariance(self):
        """Width variants of same operations should produce identical signatures."""
        from redb.extractors.decompiler.apk.method_extractor import compute_minhash
        body_int = """\
add-int v0, v1, v2
sub-int v3, v0, v1
mul-int v4, v0, v3
return v4
"""
        body_long = """\
add-long v0, v2, v4
sub-long v6, v0, v2
mul-long v8, v0, v6
return-wide v8
"""
        sig_int = compute_minhash(body_int)
        sig_long = compute_minhash(body_long)
        # Both normalize to ALU, ALU, ALU, RET -> identical
        assert sig_int == sig_long

    def test_minhash_different_apis_differ(self):
        """Methods calling different APIs should produce different signatures."""
        from redb.extractors.decompiler.apk.method_extractor import compute_minhash
        body_a = """\
const/4 v0, 0x0
invoke-virtual {p0, v0}, Lcom/crypto/AES;->encrypt([B)[B
invoke-virtual {v0}, Ljava/io/OutputStream;->write([B)V
return-void
"""
        body_b = """\
const/4 v0, 0x0
invoke-virtual {p0, v0}, Ljava/lang/String;->length()I
invoke-virtual {v0}, Ljava/io/PrintStream;->println(I)V
return-void
"""
        sig_a = compute_minhash(body_a)
        sig_b = compute_minhash(body_b)
        assert sig_a != sig_b

    def test_minhash_too_few_instructions(self):
        from redb.extractors.decompiler.apk.method_extractor import compute_minhash
        assert compute_minhash("return-void\nnop") is None


class TestACFGBlockFeatures:
    """Tests for per-block ACFG feature extraction via smali_cfg."""

    def test_simple_linear_method(self):
        from redb.extractors.decompiler.apk.smali_cfg import compute_cfg_metrics
        body = """\
add-int v0, v1, v2
invoke-virtual {p0}, Lcom/Foo;->bar()V
return-void
"""
        metrics = compute_cfg_metrics(body)
        assert metrics.block_count >= 1
        assert len(metrics.block_features) == metrics.block_count
        # Each feature vector has 8 elements
        for feat in metrics.block_features:
            assert len(feat) == 8

    def test_branching_method_has_multiple_blocks(self):
        from redb.extractors.decompiler.apk.smali_cfg import compute_cfg_metrics
        body = """\
const/4 v0, 0x0
if-eqz v0, :cond_0
invoke-virtual {p0}, Lcom/Foo;->a()V
goto :goto_0
:cond_0
invoke-virtual {p0}, Lcom/Foo;->b()V
:goto_0
return-void
"""
        metrics = compute_cfg_metrics(body)
        assert metrics.block_count >= 3
        assert len(metrics.block_features) == metrics.block_count

    def test_feature_vector_arithmetic_count(self):
        from redb.extractors.decompiler.apk.smali_cfg import compute_cfg_metrics
        body = """\
add-int v0, v1, v2
sub-int v3, v0, v1
mul-int v4, v0, v3
return v4
"""
        metrics = compute_cfg_metrics(body)
        assert len(metrics.block_features) == 1
        feat = metrics.block_features[0]
        # feat[0] = instr_count (4), feat[1] = arithmetic (3)
        assert feat[0] == 4
        assert feat[1] >= 3  # 3 ALU ops

    def test_feature_vector_call_count(self):
        from redb.extractors.decompiler.apk.smali_cfg import compute_cfg_metrics
        body = """\
invoke-virtual {p0}, Lcom/A;->a()V
invoke-static {v0}, Lcom/B;->b()V
return-void
"""
        metrics = compute_cfg_metrics(body)
        feat = metrics.block_features[0]
        # feat[4] = call count
        assert feat[4] == 2